#include <bits/stdc++.h>
using namespace std;
const int MAXN = 411;
int dp[MAXN][MAXN] = {};
vector<int> v;
map<int, int> ind;
vector<pair<int, int> > a;
inline int get(int x, int l, int e) {
  if (x > e) return 0;
  if (x + l <= e) return l;
  return e - x;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  int x, y;
  for (int i = 0; i < n; i++) {
    cin >> x >> y;
    a.push_back({x, y});
    v.push_back(x);
    v.push_back(x + y);
    v.push_back(x - y);
  }
  v.push_back(-1e9);
  v.push_back(1e9);
  sort(a.begin(), a.end());
  sort(v.begin(), v.end());
  v.resize(unique(v.begin(), v.end()) - v.begin());
  int m = v.size();
  for (int j = 0; j < m; j++)
    ind[v[j]] = j, dp[0][j] = get(a[0].first - a[0].second, a[0].second, v[j]);
  for (int i = 1; i < n; i++) {
    for (int j = 0; j < m; j++) {
      dp[i][j] = dp[i - 1][j];
      if (a[i].first - a[i].second >= v[j]) continue;
      int x = get(a[i].first, a[i].second, v[j]);
      dp[i][j] = max(dp[i][j], x + dp[i - 1][ind[min(v[j], a[i].first)]]);
      x = get(a[i].first - a[i].second, a[i].second, v[j]);
      dp[i][j] = max(dp[i][j], x + dp[i - 1][ind[a[i].first - a[i].second]]);
      int mn = a[i].first - a[i].second;
      for (int k = i - 1; k > -1; k--) {
        if (a[k].first + a[k].second > a[i].first) {
          if (!k) {
            if (mn > a[k].first)
              dp[i][j] = max(dp[i][j], dp[k - 1][ind[a[k].first]] +
                                           get(a[k].first, a[k].second, v[j]));
            else
              dp[i][j] = max(dp[i][j],
                             dp[k - 1][ind[mn]] +
                                 get(mn, a[k].second + a[k].first - mn, v[j]));
            continue;
          }
          if (mn > a[k].first)
            dp[i][j] = max(dp[i][j], dp[k - 1][ind[a[k].first]] +
                                         get(a[k].first, a[k].second, v[j]));
          else
            dp[i][j] =
                max(dp[i][j], dp[k - 1][ind[mn]] +
                                  get(mn, a[k].second + a[k].first - mn, v[j]));
        }
        mn = min(mn, a[k].first - a[k].second);
      }
    }
  }
  cout << dp[n - 1][m - 1];
}
