#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 3e2 + 10;
const long long INF = 1e18 + 10;
vector<long long> w;
pair<long long, long long> p[MAXN];
long long e[MAXN][MAXN];
long long dp[MAXN][MAXN];
long long x[MAXN];
long long d[MAXN];
long long a[MAXN];
long long l[MAXN];
long long r[MAXN];
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(0);
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> x[i] >> d[i];
    w.push_back(x[i]);
    w.push_back(x[i] - d[i]);
    w.push_back(x[i] + d[i]);
  }
  sort(w.begin(), w.end());
  w.resize(unique(w.begin(), w.end()) - w.begin());
  for (long long i = 1; i <= n; i++) {
    a[i] = lower_bound(w.begin(), w.end(), x[i]) - w.begin();
    l[i] = lower_bound(w.begin(), w.end(), x[i] - d[i]) - w.begin();
    r[i] = lower_bound(w.begin(), w.end(), x[i] + d[i]) - w.begin();
    p[i] = make_pair(a[i], i);
  }
  sort(p + 1, p + n + 1);
  for (long long i = 1; i <= n + 1; i++) {
    e[i][i - 1] = INF;
    for (long long j = i; j <= n; j++) {
      e[i][j] = min(e[i][j - 1], l[p[j].second]);
    }
  }
  for (long long i = 0; i < w.size() - 1; i++) {
    for (long long j = 1; j <= n; j++) {
      dp[i + 1][j] = dp[i][j];
      for (long long z = 1; z <= j; z++) {
        if (a[p[z].second] <= i) {
          if (r[p[z].second] > i) {
            dp[i + 1][j] =
                max(dp[i + 1][j], dp[min(a[p[z].second], e[z + 1][j])][z - 1] +
                                      w[i + 1] -
                                      w[min(a[p[z].second], e[z + 1][j])]);
          }
        } else {
          if (l[p[z].second] <= i) {
            dp[i + 1][j] =
                max(dp[i + 1][j], dp[e[z][j]][z - 1] + w[i + 1] - w[e[z][j]]);
          }
        }
      }
    }
  }
  cout << dp[w.size() - 1][n];
}
