#include <bits/stdc++.h>
using  namespace std;
#define all(x) x.begin(), x.end()
using ll = long long;
using sll = __int128;
using ld = long double;

void solve() {
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i] >> b[i];
    }
    vector<int> p(n);
    ll ans = 0, kans = 0;
    for (int i = 0; i < n; ++i) cin >> p[i];
    ll cur = 0;
    int c = 0;
    for (int i = 0; i < n; ++i) {
        if (b[i] > 0) c++;
        cur += a[i] + b[i] * c;
        if (cur > ans) {
            ans = cur;
            kans = i;
        }
    }
    cout << ans;
}
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
}