#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
#define endl '\n'
#define ll long long
#define pi pair<int, int>
#define f first
#define s second

const int mxn = 100000;
int n;
pi a[mxn];

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	
	for(int i = 0, j = 0; i < n; i++) cin >> a[i].f >> a[i].s;
	
	sort(a, a + n);
	
	ll ret = a[0].s;
	for(int i = 1, j = a[0].f + a[0].s; i < n; i++){
		ret += a[i].s + max(0, a[i].f - j);
		j = max(j, a[i].f + a[i].s);
	}
	
	cout << ret << endl;
	
	return 0;
}