//#pragma GCC optimize("Ofast,unroll-loops,fast-math")
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define cin(v) for (auto& el : v) {cin >> el;}
#define cout(v) for(auto& el : v) {cout << el << " ";} cout << "\n";

using namespace std;
using ll = long long;
using db = double;
const ll MOD = 1e9 + 7;
const ll MOD2 = 1072005019;
const ll MOD3 = 998244353;

void solve() {
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
    }
    vector<int> p(n);
    cin(p);
    ll ans = 0, sum = 0;
    for (int i = 0; i < n; i++) {
        sum += a[i] +1ll * b[i] * i;
        ans = max(ans, sum);
    }
    cout << ans;
    return;
}

signed main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int multitest = 0;
    if (multitest) {
        int t;
        cin >> t;
        while (t--) {
            solve();
        }
    } else {
        solve();
    }
}