#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ld = long double;

const int mod = 1e9 + 7;
const int maxn = 2e5 + 1;

void solve() {
    int n; cin >> n;

    vector<ll> a(n), b(n);
    for (int i{}; i < n; i++) {
        cin >> a[i] >> b[i];
    }

    ll ans = a[0];
    vector<vector<ll>> dp(n, vector<ll> (n));
    dp[0][0] = a[0];
    for (int i = 1; i < n; i++) {
        dp[i][0] = dp[i - 1][0] + a[i];
        ans = max(ans, dp[i][0]);
        ll bst = dp[i - 1][0];
        for (int j = 1; j <= i; j++) {
            if (j < i) bst = max(bst, dp[i - 1][j]);

            dp[i][j] = bst + a[i] + b[i] * j;
            ans = max(ans, dp[i][j]);
        }
    }

    cout << ans;
}

signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int it = 1;

    //cin >> it;

    while (it--) {
        solve();
    }
}