#include <iostream>
#include <vector>

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	vector<int> a(n), b(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i] >> b[i];
	}
	vector<int> p(n);
	for (int i = 0; i < n; ++i) cin >> p[i];

	int ans = a[0];
	int sum = a[0];
	for (int i = 1; i < n; ++i) {
		sum += a[i];
		if (sum > ans) ans = sum;
	}
	cout << ans;
}