#include <bits/stdc++.h>
using namespace std;
const int N = 105;
pair<int, int> a[N];
int f[N][N][2];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d%d", &a[i].first, &a[i].second);
  sort(a + 1, a + n + 1);
  int ans = 0;
  a[0].first = -1e9;
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= i; j++)
      for (int s1 = 0; s1 < 2; s1++) {
        ans = max(ans, f[i][j][s1]);
        int rj = a[j].first + a[j].second * s1, mx = -1e9, x, y;
        for (int k = i + 1; k <= n; k++) {
          for (int s2 = 0; s2 < 2; s2++) {
            int rk = a[k].first + a[k].second * s2;
            if (mx < rk) mx = rk, x = k, y = s2;
            f[k][x][y] = max(f[k][x][y],
                             f[i][j][s1] + min(a[k].second, rk - rj) + mx - rk);
          }
        }
      }
  printf("%d", ans);
  return 0;
}
