#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <iomanip>
#include <set>
#include <cstring>
#define control cout<<"e ne"<<endl;
#define endl '\n'
#define int long long
using namespace std;
int n,a[1048576],b[1048576],p[1048576],mx;
void speed()
{
 ios_base::sync_with_stdio(false);
 cin.tie(0);
}
signed main()
{
    /*
    #ifdef ONLINE_JUDGE
    freopen("txt.in","r",stdin)
    freopen("txt.out","w",stdout)
    #endif
    */
    speed();
    cin>>n;
    int sum=0;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i]>>b[i];
        sum+=a[i];
        if(b[i]>=0)sum+=b[i]*(i-1);
        mx=max(mx,sum);
    }
    for(int i=1;i<=n;i++)cin>>p[i];
    cout<<mx<<endl;
    return 0;
}
