#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <ctime>

using namespace std;

const int maxN = 101000;

int a[maxN];
int c[maxN];

long long get_buff(vector<pair<int, int>> x) {
	sort(x.begin(), x.end());

	int buf = 0;
	int r = x[0].second;
	for (int i = 1; i < x.size(); ++i) {
		if (x[i].first > r) {
			buf += x[i].first - r;
		}
		r = max(r, x[i].second);
	}
	return buf;
}

void solve() {
	int n;
	cin >> n;

	vector<pair<int, int> > segs;

	for (int i = 0; i < n; ++i) {
		cin >> a[i] >> c[i];
		segs.push_back(make_pair(a[i], a[i] + c[i]));
	}


	long long res = 0;
	for (int i = 0; i < n; ++i) {
		res += c[i];
	}

	cout << res + get_buff(segs) << "\n";
}

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int t;
	//cin >> t;
	t = 1;


	for (int tt = 0; tt < t; ++tt) {
		solve();
	}




	return 0;

}