#include<bits/stdc++.h>

using namespace std;
using ll = long long;

int main(){
    int n;
    cin >> n;
    vector<ll> a(n), b(n), p(n);
    for (int i = 0; i<n; i++){
        cin >> a[i] >> b[i];
    }
    for (int i = 0; i<n; i++){
        cin >> p[i];
    }
    ll mx = 0;
    ll sum = 0;
    for (ll i = 0; i<n; i++){
        sum+=a[i]+(ll)b[i]*(i+1);
        mx = max(mx, sum);
    }
    cout << mx << endl;
}