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

int n;
vector <pair <long long, long long> > cities;
long long sum, maxa;

int main (){

	ios::sync_with_stdio (false);
	cin.tie (0);

	cin >> n;
	for (int i = 0; i < n; i ++){
		long long a, c;
		cin >> a >> c;
		cities.push_back ({a, c});
		sum += c;
	}
	sort (cities.begin (), cities.end ());
	maxa = cities [0].first;
	for (int i = 0; i < n; i ++){
		sum += max (0ll, cities [i].first - maxa);
		maxa = max (maxa, cities [i].first + cities [i].second);
	}
	cout << sum << '\n';

}

