#include <bits/stdc++.h>

#define int long long

using namespace std;
using ll = long long;
using ld = long double;
using sll = __int128;

const int maxn = 1e6 + 10;

int a[maxn], b[maxn], p[maxn];

void solve() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i] >> b[i];
    for (int i = 1; i <= n; i++) cin >> p[i];
    vector<int> pref(n + 1);
    for (int i = 1; i <= n; i++) pref[i] = pref[i - 1] + b[i] * (i - 1);
    // for (int i = 1; i <= n; i++) cout << pref[i] << ' ';
    cout << '\n';

    int mn = 0;
    int ans = 0;
    int sm = 0;
    for (int i = 1; i <= n; i++) {
        sm += a[i];
        ans = max(ans,sm);
        mn = min(mn, pref[i]);
    }
    cout << ans;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int test = 1;
    // cin >> test;
    while (test--) {
        solve();
    }
}