#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ld long double
#define fastio ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define elif else if
#define x first
#define y second
ll n, temp, ans;
pll a[500001];
int main(){
cin >> n;
for(int i=1; i<=n; i++){
cin >> a[i].x >> a[i].y;
}
sort(a+1, a+1+n);
for(int i=1; i<=n; i++){
temp=max(temp - a[i].x + a[i-1].x, 0ll)+a[i].y;
ans=max(ans, temp);
}
cout << ans << endl;
}