#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <random>
#include <cmath>

using namespace std;

#pragma GCC optimize("O3")
#pragma GCC target("avx2")

#define int long long
#define all(a) a.begin(),a.end()
#define endl '\n'
#define pii pair<int, int>
#define pb emplace_back
typedef long double ld;

int const N = 2e6, M = 1e2 + 5, INF = 2e9;
int mod = 998244353, mod2 = 1e9 + 9;
int P = 1e9 + 7;

int add(int a, int b) {
	return (a + b) % mod2;
}

int mul(int a, int b) {
	return (a * b) % mod2;
}

int sub(int a, int b) {
	a -= b;
	if (a < 0) a += mod2;
	return a;
}

int binpow(int x, int p) {
	if (p == 0) return 1;
	int res = binpow(x, p / 2);
	if (p % 2 == 0) {
		return res * res % mod;
	}
	return (res * res % mod) * x % mod;
}


int a[N], b[N], p[N];
int dp[M][M];

int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	int n; cin >> n;

	for (int i = 0; i < n; ++i) cin >> a[i] >> b[i];
	int mx = -1, mn = 1;

	for (int i = 0; i < n; ++i) {
		mx = max(mx, b[i]);
		mn = min(mn, b[i]);
	}

	for (int i = 0; i < n; ++i) cin >> p[i];
	
	for (int i = 0; i < n; ++i) {
		for (int t = 0; t <= i; ++t) {
			for (int c = 0; c <= t; ++c) {
				dp[i][t] = max(dp[i][t], dp[i - 1][c] + a[i] + b[i] * t);
			}
		}
	}

	int ans = 0;
	for (int t = 0; t <= n; ++t) {
		ans = max(ans, dp[n - 1][t]);
	}
	cout << ans << endl;

	return 0;
	if (mx <= 0) {
		int sum = 0;
		int cur = 0;
		int ans = 0;
		for (int i = 0; i < n; ++i) {
			cur += a[i];
			ans = max(ans, cur);
		}
		cout << ans;
	}
	else if (mn >= 0) {
		int sum = 0;
		int cur = 0;
		int ans = 0;
		for (int i = 0; i < n; ++i) {
			cur += a[i] + b[i] * (i);
			ans = max(ans, cur);
		}
		cout << ans;
	}
	else {
		int sum = 0;
		int cur = 0;
		int ans = 0;
		for (int i = 0; i < n; ++i) {
			if (b[i] >= 0) cur += a[i] + b[i] * (i);
			else cur += a[i];
			ans = max(ans, cur);
		}
		cout << ans;
	}

	return 0;
}