#include <bits/stdc++.h>
int p[3010], l[3010], r[3010];
int v[3010], tot;
int nxt[3010];
long long M[3010][3010][2];
std::vector<int> ret[3010];
int n;
inline void getmax(long long &a, long long b) {
  if (a < b) a = b;
}
inline int get(int a, int b, int c) { return c ? b + 1 : a + 1; }
long long work(int now, int fa, int op) {
  if (now > fa) fa = now, op = 0;
  if (now > tot) return 0;
  long long &F = M[now][fa][op];
  if (~F) return F;
  F = work(now + 1, fa, op);
  if ((!op || (now < fa)) && nxt[now] > fa)
    getmax(F, work(get(now, fa, op), nxt[now], 0) + v[nxt[now]] - v[fa]);
  for (int i : ret[now]) {
    if (i > fa) getmax(F, work(get(now, fa, op), i, 1) + v[i] - v[fa]);
  }
  return F;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d%d", p + i, l + i);
    v[++tot] = p[i] - l[i];
    v[++tot] = p[i];
    v[++tot] = p[i] + l[i];
  }
  tot =
      (std::sort(v + 1, v + tot + 1), std::unique(v + 1, v + tot + 1) - v - 1);
  for (int i = 0; i < n; i++) {
    int L = std::lower_bound(v + 1, v + tot + 1, p[i] - l[i]) - v,
        P = std::lower_bound(v + 1, v + tot + 1, p[i]) - v,
        R = std::lower_bound(v + 1, v + tot + 1, p[i] + l[i]) - v;
    nxt[P] = R;
    ret[L].push_back(P);
  }
  memset(M, -1, sizeof M);
  printf("%lld\n", work(1, 1, 0));
  return 0;
}
