#include<bits/stdc++.h>

#define int long

using namespace std;

const int MAXN = 5031, INF = 1e18;

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<pair<int, int>> a(n + 1);
    for(int i = 1; i <= n; i++){
        cin >> a[i].first >> a[i].second;
    }
    vector<int> p(n);
    for(int i = 0; i < n; i++) cin >> p[i];
    int ans = 0;
    int sm = 0;



    for(int i = 1; i <= n; i++){
        if(a[i].second < 0) sm += a[i].first;
        else sm += a[i].first + a[i].second * (i - 1);
        ans = max(ans, sm);
    }
    cout << ans;
}
/*
10 5
1 2 2 2 3 4 5 6 7 8
1 1
1 2
1 3
1 4
2 3
*/