#include <bits/stdc++.h>
#define i64 long long
#define sz(a) int((a).size())
#define all(a) (a).begin(), (a).end()
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define per(i, a, b) for (int i = (b) - 1; i >= (a); --i)
using namespace std;

const int N = 2e5;
int n, a[N], c[N], o[N];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	cin >> n; i64 res = 0;
	rep(i, 0, n) {cin >> a[i] >> c[i], res += c[o[i] = i];}
	sort(o, o + n, [&](int i, int j) {return a[i] < a[j];});
	int mx = a[o[0]] + c[o[0]];
	rep(i, 1, n) {
		if (mx < a[o[i]]) {res += a[o[i]] - mx;}
		mx = max(mx, a[o[i]] + c[o[i]]);
	}
	cout << res << '\n';
	return 0;
}