#include <bits/stdc++.h>


using namespace std;

using ll = long long;
using pii = pair<int, int>;
const ll mod = 998244353;



signed main() {
#ifdef LOCAL
    freopen("input", "r", stdin);
#else
    ios::sync_with_stdio(0);
    cin.tie(0);
#endif
    int n;
    cin >> n;
    vector<pii> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i].first >> a[i].second;
    }
    ll mx = 0;
    ll sum = 0;
    for (int i =  0; i < n; i++) {
        sum += a[i].first + a[i].second * i;
        mx = max(sum, mx);
    }

    cout << mx << endl; 
}