#include <bits/stdc++.h>
using namespace std;
#define int long long


void solve() {
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; i++)
        cin >> a[i] >> b[i];
    
    vector<vector<int>> dp(n, vector<int>(n));
    int ans =-2e18;
    for (int t = 0; t < n; t++) {
        for (int i = t; i < n; i++) {
            dp[t][i] = a[i] + b[i] * t;
            if (t == 0) {
                if (i > 0)
                    dp[t][i] += dp[t][i - 1];
            } else {
                if (i == t)
                    dp[t][i] += max(dp[t - 1][i], dp[t - 1][i - 1]);
                else
                    dp[t][i] += max({dp[t - 1][i], dp[t][i - 1], dp[t - 1][i - 1]});
            }
            ans = max(ans, dp[t][i]);
        }
    }
    cout << ans;
}


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t = 1;
    if (t == 0) cin >> t;
    while (t--) solve();
    return 0;
}
