#include <bits/stdc++.h>
using namespace std;
const int maxN = 305;
const long long INF = 1e18;
int n, cnt;
int a[maxN + 1], b[maxN + 1];
int t[maxN + 1], L[maxN + 1];
long long f[2][maxN + 1][maxN + 1];
inline void chkmx(long long &x, long long y) { x = x > y ? x : y; }
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d %d", &a[i], &b[i]);
    t[++cnt] = a[i] - b[i];
    t[++cnt] = a[i];
    t[++cnt] = a[i] + b[i];
  }
  sort(t + 1, t + cnt + 1);
  cnt = unique(t + 1, t + cnt + 1) - t - 1;
  for (int i = 1; i <= cnt; i++) L[i] = -1;
  for (int i = 1; i <= n; i++) {
    int x = lower_bound(t + 1, t + cnt + 1, a[i]) - t;
    L[x] = b[i];
  }
  int now = 0;
  for (int j = 0; j <= cnt; j++)
    for (int k = 0; k <= cnt; k++) f[now][j][k] = -INF;
  f[now][0][0] = 0;
  for (int i = 1; i < cnt; i++) {
    now ^= 1;
    for (int j = 0; j <= cnt; j++)
      for (int k = 0; k <= cnt; k++) f[now][j][k] = -INF;
    int v = t[i + 1] - t[i];
    for (int j = 0; j < i; j++)
      for (int k = 0; k < i; k++) {
        if (f[now ^ 1][j][k] == -INF) continue;
        long long res = f[now ^ 1][j][k];
        if (L[i] == -1) {
          if (j > 0 || (k > 0 && t[k] + L[k] > t[i]))
            chkmx(f[now][j][k], res + v);
          else {
            chkmx(f[now][j][k], res);
            chkmx(f[now][i][k], res + v);
          }
        } else {
          if (!j || t[i] - L[i] <= t[j]) {
            if (k > 0 && t[k] + L[k] > t[i])
              chkmx(f[now][0][k], res + v);
            else
              chkmx(f[now][0][k], res), chkmx(f[now][i][k], res + v);
          } else
            chkmx(f[now][j][k], res + v);
          if (!k || t[i] + L[i] >= t[k] + L[k])
            chkmx(f[now][j][i], res + v);
          else
            chkmx(f[now][j][k], res + v);
        }
      }
  }
  long long ans = -INF;
  for (int k = 0; k <= cnt; k++) chkmx(ans, f[now][0][k]);
  printf("%lld\n", ans);
  return 0;
}
