#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<map>
#include<algorithm>
#include<iomanip>
#include <stdio.h>
#include<memory.h>
#include<cstdio>
#include<math.h>
#include <fstream>
#include<stack>
using namespace std;
 
typedef long long ll;
 
ll dp[100005]={0};
 
struct aa
{
	ll x;
	ll y;
}p[100005]={0};
 
bool cmp(aa a,aa b)
{
	if(a.x==b.x) return a.y<b.y;
	return a.x<b.x;
}
 
ll vis[100005]={0},n,ans=0;
 
int main()
{
	ll t,i,j,z1,z2,maxnow,ans=0;
	cin>>n;
 
	for(i=0;i<n;i++)
	    scanf("%lld %lld",&p[i].x,&p[i].y);
 
	z1=p[0].x;z2=p[0].y;
 
	sort(p,p+n,cmp);
 
	maxnow=p[0].x+p[0].y;
 
	for(i=0;i<n;i++)
	{
		ans+=p[i].y;
 
		if(maxnow<p[i].x)
		    ans+=p[i].x-maxnow;
		maxnow=max(maxnow,p[i].x+p[i].y);
 
	}
 
	printf("%lld",ans);
 
	return 0;
}