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

template <typename T> void chmin(T&x,const T &y)
{
	if(x>y)x=y;
}
template <typename T> void chmax(T &x,const T &y)
{
	if(x<y)x=y;
}
typedef int64_t s64;
typedef uint64_t u64;
typedef uint32_t u32;
typedef pair<int,int> pii;
#define rep(i,l,r) for(int i=l;i<=r;++i)
#define per(i,r,l) for(int i=r;i>=l;--i)
#define rep0(i,l,r) for(int i=l;i<r;++i)
#define gc (c=getchar())
char readc()
{
	char c;
	while(isspace(gc));
	return c;
}
int read()
{
	char c;
	while(gc<'-');
	if(c=='-')
	{
		int x=gc-'0';
		while(gc>='0')x=x*10+c-'0';
		return -x;
	}
	int x=c-'0';
	while(gc>='0')x=x*10+c-'0';
	return x;
}
#undef gc

const int N=1e5+5;
struct T{
	int x,y;
}a[N];

int main()
{
#ifndef ONLINE_JUDGE 
	freopen("1.in","r",stdin);//freopen("1.out","w",stdout);
#endif
	int n;
	cin>>n;
	s64 ans=0;
	rep(i,1,n){
		a[i].x=read();
		a[i].y=read();
		ans+=a[i].y;a[i].y+=a[i].x;
	}
	sort(a+1,a+n+1,[&](T x,T y){return x.x<y.x;});
	int now=a[1].x;
	rep(i,1,n){
		while(i<=n&&a[i].x<=now)
			chmax(now,a[i++].y);
		if(i<=n){
			ans+=a[i].x-now;
			chmax(now,a[i].y);
		}
	}
	cout<<ans<<endl;
}