#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long ll;

void solve() {
    int n;
    cin >> n;
    vector<ll> a(n), b(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
    }
    vector<int> p(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }
    ll ans = 0;
    vector<ll> lev(n);
    for (int i = 0; i < n; i++) {
        lev[i] = a[i] + b[i] * i;
        if (i) {
            lev[i] += lev[i - 1];
        }
    }
    for (int i = 0; i < n; i++) {
        ans = max(ans, lev[i]);
    }
    cout << ans;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int T = 1;
    //cin >> T;
    while (T--) {
        solve();
    }
    return 0;
}
