#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100010;
tuple<int, int, int> arr[MAXN];
int dp_end[MAXN], dp_start[MAXN];
int main() {
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		int a, c, ii;
		scanf("%d %d", &a, &c); ii = i;
		arr[i] = {a, c, ii};
	}
	sort(arr + 1, arr + n + 1);
	int answer = 0;
	int l = get<0>(arr[1]);
	for (int i = 1; i <= n; i++) {
		answer += max(0, get<0>(arr[i]) - l);
		l = max(l, get<0>(arr[i]) + get<1>(arr[i]));
	}
	long long ans = answer;
	for (int i = 1; i <= n; i++) {
		ans += get<1>(arr[i]);
	}
	printf("%lld\n", ans);
	return 0;
}