#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
#include <limits>

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

const int INF = 1e9 + 7;
const ll LL_INF = 4e18;

struct Student {
    ll a, b;
};

int main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    int n;
    cin >> n;

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

    vector<int> p(n);
    for (int i = 0; i < n; ++i) {
        cin >> p[i];
    }

    ll ans = -LL_INF;
    ll cur = 0;

    for (int i = 0; i < n; ++i) {
        if (arr[i].b <= 0) {
            cur += arr[i].a;
        } else {
            cur += (arr[i].a + arr[i].b * i);
        }
        ans = max(ans, cur);
    }

    cout << ans;

    return 0;
}