
#include <bits/stdc++.h>

#define int long long
#define ll long long
#define pii pair<int, int>

using namespace std;

const int mod = 998244353;


signed main() {
    int n; cin >> n;
    vector<int> a(n), b(n);
    vector<int> pref(n + 1);
    for (int i = 0; i < n; ++i) {
        cin >> a[i] >> b[i];
    }
    for (int i = 0; i < n; ++i) {
        pref[i + 1] = pref[i] + a[i] + max(i * b[i], 0ll);
    }
    int ans = 0;
    for (auto &x : pref) {
        ans = max(ans, x);
    }
    cout << ans;
}

