#include<bits/stdc++.h>
using namespace std;
#define IO ios::sync_with_stdio(false);cin.tie(0)
#define ll long long
#define rep(i, a, b) for(int i = a; i <= b; i++)
#define per(i, a, b) for(int i = b; i >= a; i--)
#define mem(a) memset(a, 0, sizeof a)
const int maxn = 1e5 + 10;
const ll inf = 0x3f3f3f3f, mod = 1e9+7;

pair<int, int> a[maxn];

int main(){
	IO;
	int n; cin >> n;
	ll ans = 0ll;
	rep(i, 1, n){
		cin >> a[i].first >> a[i].second;
		ans += a[i].second;
	}
	sort(a+1, a+1+n);
	int tmp = a[1].first + a[1].second;
	rep(i, 2, n){
		if(a[i].first > tmp) ans += a[i].first - tmp;
		tmp = max(tmp, a[i].first + a[i].second);
	}
	cout << ans << '\n';
}


  		  	 	 				 	 			 		  	    	