#include <bits/stdc++.h>
using namespace std;
const int N = 105;
pair<int, int> p[N];
int n, a[N], b[N], f[N][N][2], ans;
signed main() {
  cin >> n;
  a[0] = -1E9;
  for (int i = 1; i <= n; ++i) cin >> p[i].first >> p[i].second;
  sort(p + 1, p + n + 1);
  for (int i = 1; i <= n; ++i) a[i] = p[i].first, b[i] = p[i].second;
  for (int i = 0; i <= n; ++i)
    for (int j = 0; j <= i; ++j)
      for (int k = 0; k <= 1; ++k) {
        ans = max(ans, f[i][j][k]);
        int p = a[j] + k * b[j], t = -1E9, q, u, v;
        for (int x = i + 1; x <= n; ++x)
          for (int y = 0; y <= 1; ++y) {
            q = a[x] + y * b[x];
            if (q > t) t = q, u = x, v = y;
            f[x][u][v] = max(f[x][u][v],
                             f[i][j][k] + t - max(p, y ? a[x] : a[x] - b[x]));
          }
      }
  cout << ans;
}
