#include <bits/stdc++.h>
#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define endl '\n'
#define N 200005
#define fi first
#define se second
#define pb push_back
using namespace std;
const int inf=0x3f3f3f3f;
const double ex=acos(-1);
const int mod=1e11+3;
int gcd(int a,int b){return b? gcd(b,a%b) : a ;}
typedef pair<int,int>PII;
priority_queue<int,vector<int>,greater<int> > q;
int a[N];
signed main()
{ios
int t = 1, x , r;
vector<PII>v;
cin >> t;
while (t--)
{
cin >>x>>r;
v.pb({x-r,x+r});
}
sort(v.begin(),v.end());
int res=v[0].se,ans=0;
for(int i=1;i<v.size();i++)
{
if(v[i].fi>res)
{
ans+=v[i].fi-res;res=v[i].se;
}else{
res=max(res,v[i].se);
}
}
cout <<ans;
return 0;
}