#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000007;
vector<long long> X;
vector<long long> B;
vector<long long> C;
vector<long long> dp;
long long M;
const long long INF = (long long)1 << 60;
long long rec(long long a) {
  if (a == M - 1) return 0;
  if (dp[a] == -1) {
    {
      long long mx = a + 1;
      for (long long i = a + 1; i <= mx; i++) {
        if (B[i] != -1) {
          long long t =
              lower_bound(X.begin(), X.end(), X[i] + B[i]) - X.begin();
          mx = max(mx, t);
        }
      }
      dp[a] = X[a + 1] - X[a] + rec(mx);
    }
    for (long long k = a + 1; k < M; k++) {
      if (B[k] != -1) {
        if (X[a] >= X[k] - B[k]) {
          long long mx = k;
          for (long long i = a + 1; i <= mx; i++) {
            if (B[i] != -1 && k != i) {
              long long t =
                  lower_bound(X.begin(), X.end(), X[i] + B[i]) - X.begin();
              if (mx < t) {
                mx = t;
              }
            }
          }
          dp[a] = min(dp[a], rec(mx));
        }
      }
    }
    return dp[a];
  } else {
    return dp[a];
  }
}
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long N;
  cin >> N;
  vector<long long> A(N);
  vector<long long> L(N);
  long long res = 0;
  for (long long i = 0; i < N; i++) {
    cin >> A[i] >> L[i];
  }
  set<long long> st;
  for (long long i = 0; i < N; i++) {
    st.insert(A[i] - L[i]);
    st.insert(A[i]);
    st.insert(A[i] + L[i]);
  }
  for (auto s : st) {
    X.push_back(s);
  }
  M = X.size();
  B.resize(X.size(), -1);
  C.resize(X.size(), -1);
  dp.resize(X.size(), -1);
  for (long long i = 0; i < N; i++) {
    long long t = lower_bound(X.begin(), X.end(), A[i]) - X.begin();
    B[t] = L[i];
    for (long long j = t - 1; j >= 0 && X[j] >= A[i] - L[i]; j--) {
      C[j] = max(C[j], t);
    }
  }
  cout << X.back() - X[0] - rec(0) << endl;
}
