#include <bits/stdc++.h>
using namespace std;
const long double pi = 3.1415926535897932384626433832795l;
template <typename T>
inline auto sqr(T x) -> decltype(x * x) {
  return x * x;
}
template <typename T1, typename T2>
inline bool umx(T1& a, T2 b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T1, typename T2>
inline bool umn(T1& a, T2 b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
const int N = 100;
const int X = 100000000;
struct Input {
  int n;
  int a[N], b[N];
  bool read() {
    if (!(cin >> n)) {
      return 0;
    }
    for (int i = int(0); i < int(n); ++i) {
      scanf("%d%d", &a[i], &b[i]);
    }
    return 1;
  }
  void init(const Input& input) { *this = input; }
};
struct Data : Input {
  int ans;
  void write() { cout << ans << endl; }
  virtual void solve() {}
  virtual void clear() { *this = Data(); }
};
struct Solution : Data {
  int d[N + 1][N][2];
  void solve() {
    {
      vector<pair<int, int> > v(n);
      for (int i = int(0); i < int(n); ++i) {
        v[i] = make_pair(a[i], b[i]);
      }
      sort((v).begin(), (v).end());
      for (int i = int(0); i < int(n); ++i) {
        tie(a[i], b[i]) = v[i];
      }
    };
    ;
    for (int i = int(0); i < int(N); ++i) {
      for (int j = int(0); j < int(N); ++j) {
        for (int t = int(0); t < int(2); ++t) {
          d[i][j][t] = -10 * X;
        }
      }
    }
    ans = -10 * X;
    for (int i = int(0); i < int(n + 1); ++i) {
      for (int j = int(-1); j < int(i); ++j) {
        for (int tj = int(0); tj < int(2); ++tj) {
          int rj = (j == -1) ? -10 * X : a[j] + tj * b[j];
          int val_j = (j == -1) ? 0 : d[i][j][tj];
          ;
          umx(ans, val_j);
          int mx_r = -10 * X;
          int bst_k = -1;
          int bst_dir = -1;
          for (int k = int(i); k < int(n); ++k) {
            for (int tk = int(0); tk < int(2); ++tk) {
              int rk = a[k] + tk * b[k];
              if (umx(mx_r, rk)) {
                bst_k = k;
                bst_dir = tk;
              }
              umx(d[k + 1][bst_k][bst_dir],
                  val_j + min(b[k], rk - rj) + (mx_r - rk));
            }
          }
        }
      }
    }
  }
  void clear() { *this = Solution(); }
};
Solution sol;
int main() {
  cout.setf(ios::showpoint | ios::fixed);
  cout.precision(20);
  sol.read();
  sol.solve();
  sol.write();
  return 0;
}
