#include <bits/stdc++.h>
using namespace std;
mt19937 rnd(time(0));
constexpr int MAXN = 1e6 + 5;
int a[MAXN];
int b[MAXN];
int p[MAXN];
void solve(){
    int n;
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> a[i] >> b[i];
    }
    for (int i = 0; i < n; i++){
        cin >> p[i];
    }
    long long ans = 0;
    long long mx = 0;
    long long ans2 = 0;
    long long mx2 = 0;
    for (int i = 0; i < n; i++){
        ans += a[i];
        mx = max(mx, ans);
        ans2 += a[i] + i * b[i];
        mx2 = max(mx2, ans2);
    }
    cout << max(mx, mx2) << '\n';
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int t = 1;
    while (t--){
        solve();
    }
}

