using ll = long long;
using namespace std;
#include <iostream>
#include <vector>
#include <algorithm>
#define all(x) (x).begin(), (x).end()
#pragma GCC optimize("O3")
// #pragma GCC optimize("Ofast")
int main() {
    ll n;
    cin >> n;
    vector <ll> a(n), b(n), p(n);
    for (ll i = 0; i < n; ++i) {
        cin >> a[i] >> b[i];
    }
    for (ll i = 0; i < n; ++i)
        cin >> p[i];
    ll ans = 0, cur = 0;
    for (ll i = 0; i < n; ++i) {
        cur += a[i] + b[i] * i;
        ans = max(ans, cur);
    }
    cout << ans;
}