#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(a) a.begin(), a.end()
const int MAXN = 1e6 + 1, MOD = 998244353;

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];
    }
    ll ans = 0;
    ll mx = -1e18;
    for (int i = 0; i < n; ++i) {
        ans += a[i] + b[i] * i;
        mx = max(mx, ans);
    }
    cout << mx << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
}
