
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#pragma GCC optimize("03")
#pragma GCC optimize("unroll-loops")

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define int long long

using pii = pair <int, int>;
const int inf = 1e12;
const int maxn = 1e6 + 1;
vector <vector <int>> g(maxn);
vector <int> h(maxn), sz(maxn);

void dfs(int v, int p = -1) {
    sz[v] = 1;
    for (auto u : g[v]) {
        if (u != p) {
            h[u] = h[v] + 1;
            dfs(u, v);
            sz[v] += sz[u];
        }
    }
}
vector <int> pws(maxn);

const int mod = 998244353;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    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, -inf));
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        int pref = (i == 0 ? 0 : -inf);
        for (int j = 0; j <= i; ++j) {
            if (i > 0) pref = max(pref, dp[i - 1][j]);
            dp[i][j] = max(dp[i][j], pref + a[i] + b[i] * j);
        }
        ans = max(ans, *max_element(all(dp[i])));
    }
    cout << ans;
}