#include <bits/stdc++.h>

using namespace std;

#define f(i, n) for(int i=0;i<n;i++)
#define f1(i, n) for(int i=1;i<n;i++)
#define int long long
#define ll long long
// #define ll __int128_
#define MOD (ll)998244353
#define vi vector<int>
#define vvi vector<vi>
#define vll vector<ll>
#define vvll vector<vll>

vi as, bs;
ll gt(int in, ll t)
{
    return as[in] + t * bs[in];
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n;
    cin >> n;
    as = vi(n);
    bs = vi(n);
    f(i, n)
        cin >> as[i] >> bs[i];
    
    vi ps(n);
    f(i, n)
        cin >> ps[i];
    vvll dp(n, vi(1, -9e18));
    dp[0][0] = gt(0, 0);
    ll res = max(dp[0][0], (ll)0);
    f1(i, n)
    {
        // ll prma = -9e18;
        // for (int t = 0; t <= i; t++)
        // {
        //     prma = max(prma, dp[i-1][t]);
        //     dp[i][t] = prma + gt(i, t);
        //     res = max(res, dp[i][t]);
        // }
        dp[i][0] = dp[i-1][0] + gt(i, i);
        res = max(res, dp[i][0]);
    }
    cout << res << '\n';
    return 0;
}