#include <bits/stdc++.h>
using namespace std;
const int N = 105;
int dp[N][N][2];
pair<int, int> v[N];
int main() {
  int n, i, j, k, t, u;
  cin >> n;
  for (i = 1; i <= n; ++i) scanf("%d%d", &v[i].first, &v[i].second);
  v[0].first = -1e9;
  sort(v, v + n + 1);
  int maxi, r, ret = 0, a, b, l;
  for (i = 0; i <= n; ++i)
    for (j = 0; j <= i; ++j)
      for (k = 0; k < 2; ++k) {
        r = v[j].first + k * v[j].second;
        ret = max(ret, dp[i][j][k]);
        maxi = -1, a = 0, b = 0;
        for (t = i + 1; t <= n; ++t)
          for (u = 0; u < 2; ++u) {
            l = v[t].first + u * v[t].second;
            if (maxi < l) maxi = l, a = t, b = u;
            dp[t][a][b] = max(dp[t][a][b],
                              dp[i][j][k] + min(v[t].second, l - r) + maxi - l);
          }
      }
  cout << ret << endl;
}
