#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define ins insert

using namespace std;

struct ve {
    int v1;
    int v2;
};

int32_t main()
{
    int n, m, i, j, k, k1, k2, k3, x, x1, x2, x3, t, g;
    cin >> n;
    vector <ve> a;
    for (i = 0; i < n; i++) {
        cin >> x1 >> x2;
        a.pb({x1, x2});
    }
    vector <int> b(n);
    for (auto &it : b)
        cin >> it;
    vector <int> p;
    p.pb(0);
    for (i = 0; i < n; i++)
        p.pb(p.back() + a[i].v1);
    vector <int> pref;
    pref.pb(0);
    k = 0;
    for (i = 0; i < n; i++) {
        pref.pb(max(pref.back() + a[i].v1 + a[i].v2 * i, p[i + 1]));
    }
    int ans = 0;
    for (auto z : pref)
        ans = max(ans, z);
    cout << ans;
    return 0;
}
