#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const int MC = 200010;
int N;
LL x[MC];
LL a[MC];
LL s[MC];

int main(){
	cin >> N;
	repp(i,1,N+1){
		cin >> x[i] >> a[i];
		s[i] = s[i-1] + a[i];
	}
	LL ans = 0;
	LL mx = -12345678912345678;
	repm(i,N,0){
		mx = max(mx,s[i]-x[i]);
		ans = max(ans , mx-s[i-1]+x[i]);
	}
	cout << ans << endl;
	return 0;
}
