#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using db = double;
using ldb = long double;

#pragma GCC optimize("O3,fast-math,unroll-loops")


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

	int n; cin >> n;
	ll pref = 0;
	ll mx = 0;

	for (int i = 0; i < n; i++) {
		ll a, b;
		cin >> a >> b;
		pref += a + i * b;
		mx = max(mx, pref);
	}

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

	cout << mx;
	return 0;
}
