#include <bits/stdc++.h>
using namespace std;
const int N = 3005;
int n, nn, tjm, mc, ans, ls[N * 3], f[N][N * 3];
struct tjmak {
  int p, l, r;
} a[N];
bool operator<(tjmak noi, tjmak ioi) { return noi.p < ioi.p; }
int read() {
  int tmp = 0, fh = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') fh = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') tmp = tmp * 10 + c - 48, c = getchar();
  return tmp * fh;
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++) {
    ls[++nn] = a[i].p = read();
    tjm = mc = read();
    ls[++nn] = a[i].l = a[i].p - tjm;
    ls[++nn] = a[i].r = a[i].p + mc;
  }
  sort(ls + 1, ls + nn + 1);
  nn = unique(ls + 1, ls + nn + 1) - ls - 1;
  for (int i = 1; i <= n; i++) {
    a[i].p = lower_bound(ls + 1, ls + nn + 1, a[i].p) - ls;
    a[i].l = lower_bound(ls + 1, ls + nn + 1, a[i].l) - ls;
    a[i].r = lower_bound(ls + 1, ls + nn + 1, a[i].r) - ls;
  }
  sort(a + 1, a + n + 1);
  for (int i = 0; i < n; i++)
    for (int j = a[i].p; j <= nn; j++)
      if ((i == 0 && j == 0) || f[i][j] > 0) {
        tjm = max(j, a[i + 1].r);
        mc = ls[tjm] - ls[max(j, a[i + 1].p)];
        f[i + 1][tjm] = max(f[i + 1][tjm], f[i][j] + mc);
        tjm = j;
        for (int k = i + 1; k <= n; k++) {
          tjm = max(tjm, a[k].p);
          if (a[k].l <= a[i + 1].p)
            f[k][tjm] = max(f[k][tjm], f[i][j] + ls[tjm] - ls[max(j, a[k].l)]);
          tjm = max(tjm, a[k].r);
        }
      }
  for (int i = a[n].p; i <= nn; i++) ans = max(ans, f[n][i]);
  printf("%d\n", ans);
  return 0;
}
