#include <bits/stdc++.h>
clock_t __t = clock();
namespace my_std {
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>
inline T rnd(T l, T r) {
  return uniform_int_distribution<T>(l, r)(rng);
}
template <typename T>
inline bool chkmax(T& x, T y) {
  return x < y ? x = y, 1 : 0;
}
template <typename T>
inline bool chkmin(T& x, T y) {
  return x > y ? x = y, 1 : 0;
}
template <typename T>
inline void read(T& t) {
  t = 0;
  char f = 0, ch = getchar();
  double d = 0.1;
  while (ch > '9' || ch < '0') f |= (ch == '-'), ch = getchar();
  while (ch <= '9' && ch >= '0') t = t * 10 + ch - 48, ch = getchar();
  if (ch == '.') {
    ch = getchar();
    while (ch <= '9' && ch >= '0') t += d * (ch ^ 48), d *= 0.1, ch = getchar();
  }
  t = (f ? -t : t);
}
template <typename T, typename... Args>
inline void read(T& t, Args&... args) {
  read(t);
  read(args...);
}
char __sr[1 << 21], __z[20];
int __C = -1, __zz = 0;
inline void Ot() { fwrite(__sr, 1, __C + 1, stdout), __C = -1; }
inline void print(register int x) {
  if (__C > 1 << 20) Ot();
  if (x < 0) __sr[++__C] = '-', x = -x;
  while (__z[++__zz] = x % 10 + 48, x /= 10)
    ;
  while (__sr[++__C] = __z[__zz], --__zz)
    ;
  __sr[++__C] = '\n';
}
void file() {}
inline void chktime() {}
long long ksm(long long x, int y) {
  long long ret = 1;
  for (; y; y >>= 1, x = x * x)
    if (y & 1) ret = ret * x;
  return ret;
}
}  // namespace my_std
using namespace my_std;
int n;
pair<int, int> a[500];
int p[500], c;
int P[500], L[500], R[500];
int id(int x) { return lower_bound(p + 1, p + c + 1, x) - p; }
int dp[500][500];
int main() {
  file();
  read(n);
  for (int i = (1); i <= (n); i++) read(a[i].first, a[i].second);
  sort(a + 1, a + n + 1);
  for (int i = (1); i <= (n); i++)
    p[++c] = P[i] = a[i].first, p[++c] = L[i] = a[i].first - a[i].second,
    p[++c] = R[i] = a[i].first + a[i].second;
  sort(p + 1, p + c + 1);
  c = unique(p + 1, p + c + 1) - p - 1;
  for (int i = (1); i <= (n); i++) {
    for (int j = (1); j <= (c); j++) dp[i][j] = dp[i - 1][j];
    for (int j = (1); j <= (c); j++)
      if (p[j] >= P[i])
        chkmax(dp[i][j], dp[i - 1][id(P[i])] + min(a[i].second, p[j] - P[i]));
    int k = i;
    while (k && P[k] >= L[i]) --k;
    int mx[2] = {0, 0};
    for (int j = (k + 1); j <= (i - 1); j++)
      if (!mx[0] || R[j] > R[mx[0]])
        mx[1] = mx[0], mx[0] = j;
      else if (!mx[1] || R[j] > R[mx[1]])
        mx[1] = j;
    int mn[2] = {0, 0};
    for (int j = (k + 1); j <= (i - 1); j++)
      if (!mn[0] || L[j] < L[mn[0]])
        mn[1] = mn[0], mn[0] = j;
      else if (!mn[1] || L[j] < L[mn[1]])
        mn[1] = j;
    for (int j = (1); j <= (c); j++) {
      for (int x = (0); x <= (1); x++)
        for (int y = (0); y <= (1); y++)
          if (mx[x] != mn[y] || mx[x] == 0) {
            int Mx = P[i], Mn = L[i];
            if (mx[x]) chkmax(Mx, R[mx[x]]);
            if (mn[y]) chkmin(Mn, L[mn[y]]);
            int s = id(Mn);
            if (p[j] < Mn) continue;
            chkmax(dp[i][j], dp[k][id(Mn)] + max(0, min(Mx - Mn, p[j] - Mn)));
          }
    }
    for (int j = (1); j <= (c); j++) chkmax(dp[i][j], dp[i][j - 1]);
  }
  cout << dp[n][c];
  return 0;
}
