#include <iostream>
#include <vector>
#include <queue>
using namespace std;

typedef pair<long long, int> P;

int main(void){
    long long n,x[200001],s[200001],m=0;
    //priority_queue<P, vector<P>, greater<P>> q;
    priority_queue<P> q;
    
    cin>>n;
    s[0]=0;
    for(int i=1;i<=n;i++){
        cin>>x[i]>>s[i];
        s[i]+=s[i-1];
        q.push(P(s[i]-x[i],i));
    }
    /*
    for(int i=0;i<n;i++){
        P p=q.top();
        cout<<p.second<<", "<<p.first<<endl;
        q.pop();
    }
    */
    for(int i=1;i<=n;i++){
        bool f=true;
        while(f){
            P p=q.top();
            if(p.second<i){
                q.pop();
            }else{
                //cout<<p.first-s[i-1]+x[i]<<endl;
                m=max(m,p.first-s[i-1]+x[i]);
                f=false;
            }
        }
    }
    cout<<m<<endl;
}
