#include <bits/stdc++.h>

#define LL long long
#define ull unsigned long long
#define F(i, j, k) for (int i = j; i <= k; ++i)
#define DF(i, j, k) for (int i = j; i >= k; --i)

using namespace std;

template <typename T> inline void read(T &n) {
	T w = 1;
	n = 0;
	char ch = getchar();
	while (!isdigit(ch) && ch != EOF) {
		if (ch == '-') w = -1;
		ch = getchar();
	}
	while (isdigit(ch) && ch != EOF) {
		n = (n << 3) + (n << 1) + (ch & 15);
		ch = getchar();
	}
	n *= w;
}

template <typename T> inline void write(T x) {
	T l = 0;
	ull y = 0;
	if (!x) { putchar(48); return; }
	if (x < 0) { x = -x; putchar('-'); }
	while (x) { y = y * 10 + x % 10; x /= 10; ++l; }
	while (l) { putchar(y % 10 + 48); y /= 10; --l; }
}

template <typename T> inline void writes(T x) {
	write(x);
	putchar(' ');
}

template <typename T> inline void writeln(T x) {
	write(x);
	puts("");
}

template <typename T> inline void checkmax(T &a, T b) { a = a > b ? a : b; }

template <typename T> inline void checkmin(T &a, T b) { a = a < b ? a : b; }

struct lhj {
	int pos, val, num;
}a[100100];

inline bool cmp(lhj a, lhj b) { return a.pos < b.pos; }

int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	int n;
	read(n);
	LL ans = 0;
	F(i, 1, n) {
		read(a[i].pos);
		read(a[i].val);
		a[i].num = i;
		ans += a[i].val;
	}
	sort(a + 1, a + n + 1, cmp);
	int ok = 0, now = a[1].pos + a[1].val;
	F(i, 2, n) {
		if (now < a[i].pos) ans += a[i].pos - now;
		checkmax(now, a[i].pos + a[i].val);
	}
	writeln(ans);
	return 0;
}
