#include <bits/stdc++.h>
using namespace std;
const int N = 105;
int n, dp[N][N][2];
pair<int, int> a[N];
int main() {
  ios::sync_with_stdio(false);
  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 = INT_MIN / 2;
  int ans = 0;
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= i; j++)
      for (int k = 0; k < 2; k++) {
        ans = max(ans, dp[i][j][k]);
        int o = a[j].first + a[j].second * k, mx = INT_MIN / 2, x = 0, y = 0;
        for (int l = i + 1; l <= n; l++)
          for (int q = 0; q < 2; q++) {
            int t = a[l].first + q * a[l].second;
            if (t > mx) mx = t, x = l, y = q;
            dp[l][x][y] = max(dp[l][x][y],
                              dp[i][j][k] + min(a[l].second, t - o) + mx - t);
          }
      }
  cout << ans << endl;
  return 0;
}
