#include <bits/stdc++.h>

using namespace std;

#define int long long
const int mod = 998244353;

int binpow(int a, int x) {
    int res = 1;
    while (x) {
        if (x & 1) {
            res *= a;
            res %= mod;
        }
        a *= a;
        a %= mod;
        x >>= 1;
    }
    return res;
}

void solve() {
    int n;
    cin >> n;
    vector<int>a(n);
    vector<int>b(n);
    int ln = 0;
    int mink = 0;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
    }
    int p;
    for (int i = 0; i < n; i++) {
        cin >> p;
    }
    int ans = 0;
    int tans = 0;
    for (int i = 0; i < n; i++) {
        if (b[i] < 0) {
            tans += a[i];
            ans = max(tans, ans);
        }
        else {
            tans += a[i] + b[i] * (i);
            ans = max(tans, ans);
        }
    }
    cout << ans << endl;
}

signed main() {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
    solve();
}