#define _USE_MATH_DEFINES

#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;

int main(){
	
	int N;
	cin >> N;
	
	long long int x0, x, s;
	cin >> x0 >> s;
	
	long long int mi = 0;
	long long int sum = s;
	long long int ans = s;
	
	for(int i = 1; i < N; i++){
		cin >> x >> s;
		mi = min(sum - (x - x0), mi);
		sum += s;
		ans = max(ans, sum - (x - x0) - mi);
	}
	
	cout << ans << endl;
	
	return 0;
}