#include <bits/stdc++.h>
using namespace std;
int read() {
  int x = 0, sgn = 1;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') sgn = -1;
  for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ 48);
  return x * sgn;
}
const int N = 310;
int b[N], tot, f[N][N], g[N], n;
struct segment {
  int l, p, r;
} seg[N];
bool operator<(segment a, segment b) { return a.p < b.p; }
int pos(int x) { return lower_bound(b + 1, b + tot + 1, x) - b; }
int main() {
  n = read();
  for (int i = 1, r; i <= n; i++) {
    b[++tot] = seg[i].p = read(), r = read();
    b[++tot] = seg[i].l = seg[i].p - r;
    b[++tot] = seg[i].r = seg[i].p + r;
  }
  sort(b + 1, b + tot + 1);
  tot = unique(b + 1, b + tot + 1) - b - 1;
  for (int i = 1; i <= n; i++) {
    seg[i].l = pos(seg[i].l), seg[i].r = pos(seg[i].r),
    seg[i].p = pos(seg[i].p);
  }
  sort(seg + 1, seg + n + 1);
  for (int i = 1; i <= n; i++) {
    memcpy(f[i], f[i - 1], sizeof f[i]);
    memset(g, 0, sizeof g);
    int l = seg[i].l, r = seg[i].r, p = seg[i].p;
    int nr = p;
    g[nr] = f[i - 1][l] + b[nr] - b[l];
    for (int j = i - 1; j > 0; j--) {
      nr = max(seg[j].r, nr);
      g[nr] = max(g[nr], f[j - 1][l] + b[nr] - b[l]);
    }
    for (int j = tot; j >= l; j--) {
      f[i][j] = max(g[j], f[i][j]);
      g[j - 1] = max(g[j - 1], g[j] - b[j] + b[j - 1]);
    }
    for (int j = p; j <= r; j++)
      f[i][j] = max(f[i][j], f[i - 1][p] + b[j] - b[p]);
    for (int j = 1; j <= tot; j++) f[i][j] = max(f[i][j], f[i][j - 1]);
  }
  printf("%d\n", f[n][tot]);
  return 0;
}
