#include <bits/stdc++.h>

using namespace std;

long long inf = 1e17;

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	long long n; cin >> n;
	vector<long long> a(n), b(n);
	for (long long i = 0; i < n; ++i) cin >> a[i] >> b[i];
	vector<long long> dp(n, -inf);
	dp[0] = 0;
	long long ans = -inf;
	for (long long i = 0; i < n; ++i) {
        long long pref_max = -inf;
        vector<long long> dp1(n, -inf);
        for (long long time = 0; time <= i; ++time) {
            pref_max = max(pref_max, dp[time]);
            dp1[time] = pref_max + a[i] + b[i] * time;
            ans = max(ans, dp1[time]);
        }
        dp.swap(dp1);
	}
	cout << ans << '\n';
}
