#pragma gcc optimize("Ofast")
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <set>
#include <random>
#include <bitset>
#include <string>
#include <iomanip>
#include <cmath>

using namespace std;
#define int long long
using ll = long long;
using ld = long double;

#ifdef LOCAL
#include "debug.h"
#else
#define dbg(...)
#endif
const int INF = 1e18;
signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
    }
    vector<int> l(n), r(n);
    for (int i = 0; i < n; i++) {
        r[i] = i + 1;
    }
    // vector<int> p(n);
    // int bound = 0;
    // for (int i = 0; i < n; i++) {
    //     cin >> p[i];
    //     bound = max(bound, p[i]);
    //     if (p[i] == -1) continue;
    //     r[p[i] - 1] = min(r[p[i] - 1], i + 1);
    //     for (int j = p[i]; j < n; j++) {
    //         l[j] = max(l[j], i + 1);
    //     }
    // }
    int ans = 0, pref = 0, pref2 = 0;
    for (int i = 0; i < n; i++) {
        pref += a[i];
        pref2 += b[i] * i;
        ans = max(ans, pref + pref2);
    }
    cout << ans;
}