#include<iostream> #include<algorithm> #define maxn 110 #define INF 1000000000 #define ll long long usingnamespacestd;
int n; pair<int, int> a[maxn];
int f[maxn][maxn][2]; intmain(){ ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
cin >> n; for (int i = 1; i <= n; ++i) cin >> a[i].first >> a[i].second; sort(a + 1, a + n + 1); int ans = -INF; a[0].first = -INF; fill(f[0][0], f[0][0] + maxn * maxn * 2, -INF); f[0][0][0] = 0; for (int i = 0; i <= n; ++i) for (int j = 0; j <= i; ++j) for (int k = 0; k < 2; ++k) { if (f[i][j][k] == -INF) continue; int Max = -INF, id, dir, rj = a[j].first + a[j].second * k; for (int l = i + 1; l <= n; ++l) for (int o = 0; o < 2; ++o) { int rl = a[l].first + a[l].second * o; if (Max < rl) Max = rl, id = l, dir = o; f[l][id][dir] = max(f[l][id][dir], f[i][j][k] + Max - rl + min(rl - rj, a[l].second)); } ans = max(ans, f[i][j][k]); } cout << ans << "\n"; return0; }