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


void solve() {
    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];

    int ans = 0, s = 0;
    for (int i = 0; i < n; i++) {
        s += a[i] + b[i] * i;
        ans = max(ans, s);
    }
    cout << ans;
}


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t = 1;
    if (t == 0) cin >> t;
    while (t--) solve();
    return 0;
}
