#include<iostream>
#pragma GCC optimize("Ofast")
using namespace std;

using ll = long long;
using ld = long double;

const ll infl = (ll)4e18 + 100;
const int infi = (int)1e9 + 100;
const int maxn = (int)1e6 + 10;
const int mod = (int)1e9 + 7;

int n;
int a[maxn], b[maxn];
int p[maxn];

inline void solve() {
    cin >> n;
    for (int i = 1; i <= n; ++i)
        cin >> a[i] >> b[i];
    for (int i = 1; i <= n; ++i)
        cin >> p[i];

    ll ans = -infl;
    for (int t = 0; t <= n; ++t) {
        for (int k = t + 1; k <= n; ++k) {
            ll nw = 0;
            for (int i = 1; i <= n; ++i)
                nw += a[i] + t * b[i];

            ans = max(ans, nw);
        }
    }

    cout << ans;
}

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

    int t_ = 1; // cin >> t_;
    while (t_--) {
        solve();
        cout << '\n';
    }

    return 0;
}