#include <bits/stdc++.h>
using namespace std;
const int N = 105;
long long n, f[N][N][2], ans;
pair<int, int> a[N];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i].first >> a[i].second;
  sort(a + 1, a + n + 1);
  a[0].first = -1e9;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= i; j++) {
      for (int p = 0; p <= 1; p++) {
        ans = max(ans, f[i][j][p]);
        int r1 = a[j].first + p * a[j].second, mx = -1e9, x, y;
        for (int k = i + 1; k <= n; k++) {
          for (int q = 0; q <= 1; q++) {
            int r2 = a[k].first + q * a[k].second;
            if (r2 > mx) mx = r2, x = k, y = q;
            f[k][x][y] = max(f[k][x][y],
                             f[i][j][p] + min(a[k].second, r2 - r1) + mx - r2);
          }
        }
      }
    }
  }
  printf("%lld\n", ans);
  return 0;
}
