//W4P3R
/*
----------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------
--------------------------#############------------------#############------------------------------------
------------------------###############----------------###############------------------------------------
-----------------------####---------------------------####------------------------------------------------
----------------------####---------------------------####-------------------------------------------------
----------------------####---------------------------####-------------------------------------------------
----------------------####---------####--------------####---------####------------------------------------
----------------------####---------####--------------####---------####------------------------------------
----------------------####-----------##--------------####-----------##------------------------------------
-----------------------####----------##---------------####----------##------------------------------------
------------------------###############----------------###############------------------------------------
--------------------------#############------------------#############------------------------------------
----------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------
GG
*/
#include<bits/stdc++.h>
#define inf 1e9
#define eps 1e-6
#define mp make_pair
#define pb push_back
#define fr first
#define sd second
#define pa pair<ll,ll>
#define FOR(i,a,b) for(ll i=a;i<=b;i++)
#define REP(i,a,b) for(ll i=a;i>=b;i--)
#define MEM(a) memset(a,0,sizeof(a))
#define N 100010
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
inline ll read()
{
	char ch=getchar();
	ll s=0,w=1;
	while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
	return s*w;
}
inline ll lowbit(ll x){return x&(-x);}
ll n;
struct node{ll a,c,id;}t[N];
inline ll cmp(node a,node b){return a.a<b.a;}
int main()
{
	//ios::sync_with_stdio(false);
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	n=read();ll ans=0;
	FOR(i,1,n)t[i].a=read(),t[i].c=read(),t[i].id=i,ans+=t[i].c;
	sort(t+1,t+n+1,cmp);
	ll id=0;
	ll nowv=t[1].c+t[1].a;
	FOR(i,1,n)
	{
		ans+=max(0LL,t[i].a-nowv);
		nowv=max(nowv,t[i].a+t[i].c);
	}
	cout<<ans<<'\n';
	return 0;
}
//gl
 