#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3111;
int p[MAXN], l[MAXN], r[MAXN], pid[MAXN], lid[MAXN], rid[MAXN];
int ord[MAXN * 3], mp[MAXN * 3], id[MAXN * 3];
int dp[MAXN][MAXN * 3];
int n, m, tot, sz;
inline bool cmp(int x, int y) {
  return p[x] != p[y]
             ? p[x] < p[y]
             : (p[x] - l[x] != p[y] - l[y] ? p[x] - l[x] < p[y] - l[y]
                                           : r[x] - p[x] > r[y] - p[y]);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d%d", &p[i], &l[i]);
    r[i] = l[i];
    l[i] = p[i] - l[i];
    r[i] = p[i] + r[i];
    ord[i] = i;
    mp[++tot] = p[i];
    mp[++tot] = l[i];
    mp[++tot] = r[i];
  }
  sort(ord + 1, ord + 1 + n, cmp);
  sort(mp + 1, mp + 1 + tot);
  tot = unique(mp + 1, mp + 1 + tot) - mp - 1;
  for (int i = 1; i <= n; ++i) {
    pid[ord[i]] = lower_bound(mp + 1, mp + 1 + tot, p[ord[i]]) - mp;
    lid[ord[i]] = lower_bound(mp + 1, mp + 1 + tot, l[ord[i]]) - mp;
    rid[ord[i]] = lower_bound(mp + 1, mp + 1 + tot, r[ord[i]]) - mp;
    id[pid[ord[i]]] = ord[i];
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= tot; ++j) {
      dp[i][j] = dp[i - 1][j];
    }
    for (int j = lid[ord[i]] + 1; j <= pid[ord[i]]; ++j) {
      dp[i][j] = max(dp[i][j], dp[i][j - 1] + (mp[j] - mp[j - 1]));
    }
    int mx = dp[i - 1][pid[ord[i]]];
    for (int j = pid[ord[i]] + 1; j <= rid[ord[i]]; ++j) {
      dp[i][j] = max(dp[i][j], mx + (mp[j] - mp[pid[ord[i]]]));
      if (id[j] && lid[id[j]] < pid[ord[i]]) {
        mx =
            max(mx, dp[i - 1][lid[id[j]]] + (mp[pid[ord[i]]] - mp[lid[id[j]]]));
      }
    }
    for (int j = 1; j <= tot; ++j) {
      dp[i][j] = max(dp[i][j], dp[i][j - 1]);
    }
  }
  printf("%d\n", dp[n][tot]);
  return 0;
}
