#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <set>
#include <queue>

using namespace std;

const long long MOD = 998244353;

int main() {
    int n;
    cin >> n;
    vector<pair<int, int>> v(n);
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i].first >> v[i].second;
    }
    vector<long long> pref(n + 1);
    for (int i = 1; i <= n; i++) {
        pref[i] = pref[i - 1] + v[i - 1].first;
    }
    long long mx = -1e18;
    for (int i = 0; i < n; i++) {
        mx = max(mx, pref[i]);
    }
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    long long ans = -1e18, c = 0;
    for (int i = 0; i < n; i++) {
        c += v[i].first + v[i].second * i;
        ans = max(ans, c);
    }
    cout << max(ans, mx);
}
