#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int IN() {
  char ch;
  (ch = getchar());
  int x = 0, f = 1;
  while ((ch == '\n' || ch == '\r' || ch == '\t' || ch == ' '))
    (ch = getchar());
  if (ch == '-') f = -f, (ch = getchar());
  while (!(ch == '\n' || ch == '\r' || ch == '\t' || ch == ' '))
    x = x * 10 + ch - '0', (ch = getchar());
  return f * x;
}
int Pow(int x, int y, int p) {
  int A = 1;
  for (; y; y >>= 1, x = (long long)x * x % p)
    if (y & 1) A = (long long)A * x % p;
  return A;
}
int n;
int XX[N], tot, f[505][505];
pair<int, int> a[N];
int dfs(int x, int u) {
  int t = lower_bound(XX + 1, XX + tot + 1, x) - XX;
  if (f[t][u] != -1) return f[t][u];
  int &res = f[t][u];
  if (u > n) return res = 0;
  for (int i = (int)u; i <= (int)n; i++) {
    int R = a[i].first;
    int X = i;
    int D = a[i].first - max(x, a[i].first - a[i].second);
    for (int j = u; j <= n && a[j].first <= R; j++) {
      if (j == i) continue;
      X = max(X, j);
      if (a[j].first + a[j].second > R) {
        D += a[j].first + a[j].second - R;
        R = a[j].first + a[j].second;
      }
    }
    D += dfs(R, X + 1);
    if (D > res) res = D;
  }
  int i = u;
  int RR = a[i].first + a[i].second;
  int XX = i;
  int DD = a[i].second;
  for (int j = i + 1; j <= n && a[j].first <= RR; j++) {
    XX = j;
    if (a[j].first + a[j].second > RR) {
      DD += a[j].first + a[j].second - RR;
      RR = a[j].first + a[j].second;
    }
  }
  DD += dfs(RR, XX + 1);
  if (DD > res) res = DD;
  return res;
}
int main() {
  scanf("%d", &n);
  for (int i = (int)1; i <= (int)n; i++) {
    scanf("%d%d", &a[i].first, &a[i].second);
    XX[++tot] = a[i].first + a[i].second;
    XX[++tot] = a[i].first - a[i].second;
    XX[++tot] = a[i].first;
  }
  XX[++tot] = -210000000;
  sort(XX + 1, XX + tot + 1);
  tot = unique(XX + 1, XX + tot + 1) - (XX + 1);
  sort(a + 1, a + n + 1);
  memset(f, -1, sizeof f);
  printf("%d\n", dfs(-210000000, 1));
  return 0;
}
