#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <array>
#include <unordered_set>
#include <unordered_map>

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

#define int ll

const int INF = 1e18;

struct Node {
    int a, b;
};

signed main() {
    int n;
    cin >> n;

    vector<Node> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i].a >> a[i].b;
    }

    int res = 0;
    int now = 0;
    for (int i = 0; i < n; ++i) {
        now += a[i].a;
        if (a[i].b > 0)
            now += a[i].b * i;
        res = max(res, now);
    }

    cout << res;
}