#include <bits/stdc++.h>
using namespace std;
#define int long long

vector<int> f(vector<int> a, int i) {
    int n = a.size();
    vector<int> b(n);
    if (i == 0) {
        return a;
    }
    if (i == 1) {
        for (int i = 0; i < n; i++) {
            b[i] = a[n - 1 - i];
        }
        return b;
    }
    if (i == 2) {
        for (int i = 0; i < n; i++) {
            b[i] = n + 1 - a[i];
        }
        return b;
    }
    for (int i = 0; i < n; i++) {
        b[a[i] - 1] = i + 1;
    }
    return b;
}

const int MOD = 998244353;

int pw(int a, int b) {
    //cout << a << " " << b << endl;
    if (b == 0) {
        return 1;
    }
    if (b % 2 == 1) {
        return (pw(a, b - 1) * a) % MOD;
    }
    int t = pw(a, b / 2);
    return (t * t) % MOD;
}

int g(vector<int>& a) {
    int ans = 0;
    for (int i = 0; i < a.size(); i++) {
        ans = (ans + pw(a[i], i + 1)) % MOD;
        //cout << ans << " " << a[i] << " " << i + 1 << endl;
    }
    /*
    for (auto e : a) {
        cout << e << " ";
    }
    cout << endl << ans << endl;*/
    return ans;
}

int ind(vector<vector<int>>& a, vector<int>& b) {
    for (int i = 0; i < a.size(); i++) {
        if (a[i] == b) {
            return i;
        }
    }
    return -1;
}

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n;
    cin >> n;
    vector<int> a(n), b(n), p(n);
    for (int i = 0; i < n; i++){
        cin >> a[i] >> b[i];
    }
    for (int i = 0; i < n; i++) cin >> p[i];

    vector<int> x(n, 0);
    for (int i = 0; i < n; i++) {
        if (b[i] < 0) {
            x[i] = a[i];
        } else {
            x[i] = a[i] + b[i] * (i + 0);
        }
        //cout << x[i] << " ";
    }
   // cout << endl;
    int ans = 0;
    int now = 0;
    for (auto e : x) {
        now += e;
        ans = max(ans, now);
    }
    cout << ans << endl;
}
