#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e2 + 5;
pair<int, int> seg[maxn];
int f[maxn][maxn][2];
int ans;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> seg[i].first >> seg[i].second;
  sort(seg + 1, seg + n + 1);
  seg[0].first = -(1 << 30);
  for (int i = 0; i <= n; ++i) {
    for (int j = 0; j <= i; ++j) {
      for (int k = 0; k < 2; ++k) {
        ans = max(ans, f[i][j][k]);
        int nr = seg[j].first + seg[j].second * k, mx = -(1 << 30), x = 0,
            y = 0;
        for (int l = i + 1; l <= n; ++l) {
          for (int m = 0; m < 2; ++m) {
            int tr = seg[l].first + seg[l].second * m;
            if (tr > mx) mx = tr, x = l, y = m;
            f[l][x][y] = max(
                f[l][x][y], f[i][j][k] + mx - tr + min(seg[l].second, tr - nr));
          }
        }
      }
    }
  }
  cout << ans << '\n';
  return 0;
}
