#include <bits/stdc++.h>
using namespace std;


typedef long long ll;
typedef unsigned long long ull;

const int maxn = 2e5+1;
int n;
ll x[maxn];
ll s[maxn];
ll ss[maxn];

int main()
{
  scanf("%d", &n);
  x[0] = s[0] = 0;
  for (int i = 1; i <= n; ++i)
    scanf("%lld %lld", x+i, s+i), s[i] += s[i-1];
  for (int i = 1; i <= n; ++i)
    ss[i] = s[i]-x[i];
  ll ans = 0;
  ll mini = s[0]-x[1];
  for (int i = 1; i <= n; ++i)
    {
      ans = max(ans, ss[i]-mini);
      mini = min(mini, s[i]-x[i+1]);
    }
  printf("%lld\n", ans);
		    
}
