#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll n, i, a[1000002], b[1000002], ans, p[1000002], pr[1000002];

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n;
    for (i = 1; i <= n; i++) {
        cin >> a[i] >> b[i];
    }
    for (i = 1; i <= n; i++) {
        cin >> p[i];
    }
    for (i = 1; i <= n; i++) {
        pr[i] = pr[i - 1] + a[i]+b[i]*(i-1);
        ans = max(ans, pr[i]);
    }
    cout << ans;
    return 0;
}
