#include <bits/stdc++.h>

using namespace std;

#define int long long
#define all(x) x.begin(), x.end()

const int INF = 1e18;

void solve() {
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
    }
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
    }
    int mx = 0, sum = 0;
    for (int i = 0; i < n; i++) {
        int cur = a[i];
        for (int t = 0; t < i + 1; t++) {
            cur = max(cur, a[i] + t * b[i]);
        }
        sum += cur;
        mx = max(sum, mx);
    }
    cout << mx;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
}