//#define _GLIBCXX_DEBUG
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cassert>
#include <iomanip>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>

#define int long long

using namespace std;
using ll = long long;
using ld = long double;

const int INTI = 2e9 + 5, MAXN = 1e5 + 1, MOD = 998244353;
const ll INF = 4e18 + 5;

vector<pair<int, int> > a;

void solve() {
    int n;
    cin >> n;
    a.resize(n);
    int mx = -INF;
    int sum = 0;
    for (auto& [i, j] : a) {
        cin >> i >> j;
    }
    bool fl = 0;
    for (int i = 0; i < n; ++i) {
        sum += a[i].first;
        if (a[i].second > 0)
            fl = 1;
        if (fl)
            sum += a[i].second * i;
        mx = max(mx, sum);
    }
    cout << mx;
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
    //cin >> t;
    while (t--)
        solve();
    return 0;
}
