#include <bits/stdc++.h>

using namespace std;
using ll = long long;

struct Node {
    ll a, b;
};

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    ll n;
    cin >> n;

    vector<Node> a(n);
    for (ll i = 0; i < n; ++i)
        cin >> a[i].a >> a[i].b;

    vector<ll> p(n);
    for (ll i = 0; i < n; ++i)
        cin >> p[i];

    ll ans = a[0].a, now = a[0].a;
    for (ll i = 1; i < n; ++i) {
        now += a[i].a + i * a[i].b;
        ans = max(ans, now);
    }

    cout << ans;
}