#include <bits/stdc++.h>
const int N = 1000 + 7;
int n, m;
struct str {
  int l, m, r;
} v[N];
int e[N];
int f[N][N], g[N];
int main() {
  scanf("%d", &n);
  for (int i = 1, x, y; i <= n; ++i)
    scanf("%d%d", &x, &y),
        v[i] = (str){e[i] = x - y, e[i + n] = x, e[i + n * 2] = x + y};
  std::sort(e + 1, e + n * 3 + 1);
  m = std::unique(e + 1, e + n * 3 + 1) - e - 1;
  std::sort(v + 1, v + n + 1, [](str a, str b) { return a.m < b.m; });
  for (int i = 1; i <= n; ++i)
    v[i].l = std::lower_bound(e + 1, e + m + 1, v[i].l) - e,
    v[i].m = std::lower_bound(e + 1, e + m + 1, v[i].m) - e,
    v[i].r = std::lower_bound(e + 1, e + m + 1, v[i].r) - e;
  for (int i = 1; i <= n; ++i) {
    std::fill(g + 1, g + m + 2, -1);
    g[v[i].m] = f[i - 1][v[i].l];
    for (int k = i - 1, p = 0; k; --k)
      p = std::max(p, v[k].r), g[p] = std::max(g[p], f[k - 1][v[i].l]);
    for (int j = m; j >= v[i].l; --j) {
      g[j] = std::max(g[j], g[j + 1]);
      if (g[j] >= 0) f[i][j] = std::max(f[i][j], g[j] + e[j] - e[v[i].l]);
    }
    for (int j = v[i].m; j <= v[i].r; ++j)
      f[i][j] = std::max(f[i][j], f[i - 1][v[i].m] + e[j] - e[v[i].m]);
    for (int j = 1; j <= m; ++j)
      f[i][j] = std::max(f[i][j], std::max(f[i - 1][j], f[i][j - 1]));
  }
  printf("%d", f[n][m]);
  return 0;
}
