#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
using ll = long long;
#define int ll
const int maxn = 5000;
ll dp[maxn][maxn];
ll a[maxn], b[maxn];
int p[maxn];
signed main()
{
#ifdef LOCAL
    freopen("main.in", "r", stdin);
    freopen("main.out", "w", stdout);
#endif
    int n;
    cin >> n;
    ll sum = 0;
    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i] >> b[i];
        sum += a[i];
        ans = max(ans, sum);
    }
    for (int i = 0; i < n; ++i) {
        cin >> p[i];
    }
    cout << ans;
    return 0;

    dp[0][0] = a[0];
    ans = max(ans, a[0]);
    for (int i = 1; i < n; ++i) {
        ll maxans = dp[i-1][0];
        for (int t = 0; t <= i; ++t) {
            dp[i][t] = maxans + a[i] + t * b[i];
            maxans = max(maxans, dp[i-1][t]);
            ans = max(ans, dp[i][t]);
        }
    }
    cout << ans;

}