#include <bits/stdc++.h>
using namespace std;
void upd(int& a, int b) { a = max(a, b); }
const int minf = -1e9 - 79;
class spotlight {
 public:
  int l, m, r;
};
bool cmp(spotlight& a, spotlight& b) { return a.m < b.m; }
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<spotlight> a(n);
  vector<int> x{minf};
  for (int i = 0, l; i < n; i++) {
    cin >> a[i].m >> l;
    a[i].l = a[i].m - l, a[i].r = a[i].m + l;
    x.push_back(a[i].l), x.push_back(a[i].m), x.push_back(a[i].r);
  }
  sort(a.begin(), a.end(), cmp);
  sort(x.begin(), x.end());
  x.erase(unique(x.begin(), x.end()), x.end());
  int m = x.size();
  vector<vector<int> > dp(n + 1, vector<int>(m, minf));
  dp[0].assign(m, 0);
  for (int i = 1; i <= n; i++) {
    a[i - 1].l = find(x.begin(), x.end(), a[i - 1].l) - x.begin();
    a[i - 1].m = find(x.begin(), x.end(), a[i - 1].m) - x.begin();
    a[i - 1].r = find(x.begin(), x.end(), a[i - 1].r) - x.begin();
    vector<int> maxr(i + 1, 0);
    maxr[i] = a[i - 1].m;
    for (int j = i - 1; j > 0; j--) maxr[j] = max(maxr[j + 1], a[j - 1].r);
    for (int j = 0; j < m; j++) dp[i][j] = dp[i - 1][j];
    for (int j = a[i - 1].m; j <= a[i - 1].r; j++)
      upd(dp[i][j], dp[i - 1][a[i - 1].m] + x[j] - x[a[i - 1].m]);
    for (int j = i; j > 0; j--) {
      for (int ri = a[i - 1].l; ri <= maxr[j]; ri++) {
        upd(dp[i][ri], dp[j - 1][a[i - 1].l] + x[ri] - x[a[i - 1].l]);
      }
    }
    for (int j = 1; j < m; j++) upd(dp[i][j], dp[i][j - 1]);
  }
  cout << dp[n][m - 1] << "\n";
  return 0;
}
