#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

const long long MAX = (5e3) + 5;

long long a[MAX], b[MAX], p[MAX], dp[MAX][MAX], n;

void Solve()
{
    cin >> n;
    long long op = 0, ans = 0;
    for (long long i = 1; i <= n; i++)
    {
        cin >> a[i] >> b[i];
        op += a[i];
        if (b[i] > 0)
            op += b[i] * (i - 1);
        ans = max(ans, op);
    }
    for (long long i = 1; i <= n; i++)
        cin >> p[i];
    cout << ans << endl;
    return;

    dp[1][0] = a[1];
    ans = max(1LL * 0, a[1]);
    for (long long i = 2; i <= n; i++)
    {
        for (long long j = 0; j < i; j++)
        {
            dp[i][j] = dp[i - 1][min(i - 2, j)] + a[i] + j * b[i];
            if (j > 0)
                dp[i][j] = max(dp[i][j], dp[i][j - 1]);
        }
        ans = max(ans, dp[i][i - 1]);
    }
    cout << ans << endl;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    Solve();
    return 0;
}