#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;
typedef long double ld;
#define int long long
#define pii pair<int, int>
#define F first
#define S second

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<pii> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i].F >> a[i].S;
    }
    vector<int> b(n);
    int ans = 0, ma = 0;
    for (int i = 0; i < n; i++) {
        cin >> b[i];
    }
    for (int i = 0; i < n; i++) {
        ans += a[i].F + a[i].S * i;
        ma = max(ma, ans);
    }
    cout << ma;
    return 0;
} 