#include <bits/stdc++.h>
using namespace std;
template <typename tp>
inline void read(tp &x) {
  x = 0;
  char c = getchar();
  int f = 0;
  for (; c < '0' || c > '9'; f |= c == '-', c = getchar())
    ;
  for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar())
    ;
  if (f) x = -x;
}
const int N = 666;
struct P {
  int p, l, r;
} a[N];
int x[N], x_cnt, n, id[N];
inline bool cmp_p(P a, P b) { return a.p < b.p; }
inline void U(int &x, int y) { x = max(x, y); }
int main(void) {
  read(n);
  for (int i = 1; i <= (n); i++) {
    int p, l;
    read(p);
    read(l);
    x[++x_cnt] = a[i].p = p;
    x[++x_cnt] = a[i].l = p - l;
    x[++x_cnt] = a[i].r = p + l;
  }
  sort(x + 1, x + x_cnt + 1);
  sort(a + 1, a + n + 1, cmp_p);
  for (int i = 1; i <= (n); i++) {
    (a[i].p = lower_bound(x + 1, x + x_cnt + 1, a[i].p) - x);
    (a[i].l = lower_bound(x + 1, x + x_cnt + 1, a[i].l) - x);
    (a[i].r = lower_bound(x + 1, x + x_cnt + 1, a[i].r) - x);
    id[a[i].p] = i;
  }
  vector<int> dp(x_cnt + 1, 0);
  dp[0] = 0;
  for (int i = 1; i <= n; i++) {
    auto new_dp = dp;
    for (int j = a[i].l + 1; j <= a[i].p; j++)
      U(new_dp[j], new_dp[j - 1] + x[j] - x[j - 1]);
    int premax = dp[a[i].p];
    for (int j = a[i].p + 1; j <= a[i].r; j++) {
      U(new_dp[j], premax + x[j] - x[a[i].p]);
      if (id[j] && a[id[j]].l < a[i].p)
        U(premax, dp[a[id[j]].l] + x[a[i].p] - x[a[id[j]].l]);
    }
    swap(dp, new_dp);
    for (int j = 1; j <= x_cnt; j++) U(dp[j], dp[j - 1]);
  }
  cout << dp[x_cnt] << "\n";
}
