#include<bits/stdc++.h>
#define FOR(i, x, y) for(int i = (x), i##END = (y); i <= i##END; ++i)
#define DOR(i, x, y) for(int i = (x), i##END = (y); i >= i##END; --i)
template<typename T, typename _T> inline bool chk_min(T &x, const _T &y) {return y < x ? x = y, 1 : 0;}
template<typename T, typename _T> inline bool chk_max(T &x, const _T &y) {return x < y ? x = y, 1 : 0;}
typedef long long ll;
const int N = 1e5 + 5;
struct node
{
	int a, b;
	bool operator <(const node &_) const
	{
		return a < _.a;
	}
}p[N];
ll ans;
int n;

int main()
{
	scanf("%d", &n);
	FOR(i, 1, n)
	{
		int a, c;
		scanf("%d%d", &a, &c);
		ans += c;
		p[i].a = a, p[i].b = a + c;
	}
	std::sort(p + 1, p + 1 + n);
	int mx = p[1].b;
	FOR(i, 2, n) ans += std::max(0, p[i].a - mx), chk_max(mx, p[i].b);
	printf("%lld\n", ans);
	return 0;
}