#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx2")
#pragma GCC optimize("O3" , "Ofast" , "unroll-loops" , "fast-math")

#define endl '\n'
#define X first
#define Y second
#define MOD 1000000007

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector <ll> vi;
typedef vector <long long> vll;
typedef vector <unsigned long long> vull;
typedef vector <string> vs;
typedef pair <ll, ll> pii;

void speed()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
}

const ll maxn = 1e6 + 7;
ll n;
ll a[maxn];
ll b[maxn];
ll p[maxn];
void read_solve()
{
    cin >> n;
    for(ll i = 1;i <= n;i++)
    {
        cin >> a[i] >> b[i];
    }
    for(ll i = 1;i <= n;i++)
    {
        cin >> p[i];
    }
    ll ans = 0;
    ll maxans = 0;
    for(ll i = 1;i <= n;i++)
    {
        ans += a[i];
        if(b[i] > 0)ans += b[i] * (i - 1);
        maxans = max(ans, maxans);
    }
    cout << maxans << endl;
}

int main()
{
    speed();
    read_solve();
    return 0;
}
