#include<bits/stdc++.h>

using namespace std;
#define int long long
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n , mx = 0;
    cin >> n;
    vector<int>p(n);
    vector<pair<int , int>> st;
    vector<int> prefa(n + 1) , prefb(n + 1);
    for(int i = 0 ; i< n ; i++) {
        int a , b;
        cin >> a >> b;
        prefa[i + 1] = prefa[i] + a;
        prefb[i + 1] = prefb[i] + b * (i);
        st.push_back({a , b});
    }
    for(int i = 0 ; i < n ; i++) {
        cin >> p[i];
    }
//    int mx = 0;
    for(int i = 1 ; i <= n ; i++) {
        mx  =max(mx , prefb[i] + prefa[i]);
    }
    cout << mx;

}
