#include <bits/stdc++.h>
using namespace std;
const int Maxn = 310;
const int inf = 999999999;
struct Tnode {
  int a, l, r;
};
int f[Maxn][Maxn];
bool g[Maxn][Maxn][Maxn / 3];
int decide[Maxn][Maxn];
Tnode p[Maxn];
int pos[Maxn];
int N, tot;
bool Cmp(Tnode A, Tnode B) { return A.a < B.a || (A.a == B.a && A.l > B.l); }
void update(int i, int j, int k, int last) {
  int l = pos[i], r = pos[j];
  for (int kk = 0; kk < N; ++kk)
    if (kk != k && p[kk].a > l && p[kk].a <= last) {
      if (p[kk].r <= r) last = max(p[kk].r, last);
    }
  if (last == r)
    g[i][j][k] = true;
  else {
    last = lower_bound(pos, pos + tot, last) - pos;
    for (int kk = 0; kk < N && !g[i][j][k]; ++kk)
      if (kk != k) g[i][j][k] |= g[last][j][kk];
  }
}
int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; ++i) {
    scanf("%d%d", &p[i].a, &p[i].l);
    p[i].r = p[i].a + p[i].l;
    p[i].l = p[i].a - p[i].l;
    pos[i * 3] = p[i].a;
    pos[i * 3 + 1] = p[i].l;
    pos[i * 3 + 2] = p[i].r;
  }
  sort(p, p + N, Cmp);
  sort(pos, pos + N * 3);
  tot = unique(pos, pos + N * 3) - pos;
  memset(g, false, sizeof(g));
  for (int i = tot - 1; i >= 0; --i)
    for (int j = i + 1; j < tot; ++j) {
      if (i == 1 && j == 9) printf(" ");
      int l = pos[i], r = pos[j];
      for (int k = 0; k < N; ++k)
        if (p[k].a >= l && p[k].a <= r) {
          if (p[k].l <= l) update(i, j, k, p[k].a);
          if (g[i][j][k]) continue;
          if (p[k].a == l) update(i, j, k, p[k].r);
        }
    }
  for (int i = 0; i < tot; ++i)
    for (int j = 0; j < tot; ++j) f[i][j] = -inf;
  for (int i = tot - 1; i >= 0; --i)
    for (int j = i + 1; j < tot; ++j) {
      bool flag = false;
      for (int k = 0; k < N; ++k) flag |= g[i][j][k];
      if (flag)
        f[i][j] = pos[j] - pos[i];
      else
        f[i][j] = -inf;
      f[i][j] = max(f[i][j], max(f[i][j - 1], f[i + 1][j]));
      for (int k = i + 1; k < j; ++k) {
        if (f[i][j] < f[i][k] + f[k + 1][j]) {
          f[i][j] = f[i][k] + f[k + 1][j];
          decide[i][j] = k;
        }
      }
    }
  printf("%d\n", f[0][tot - 1]);
  return 0;
}
