#include <bits/stdc++.h>
using namespace std;
const int oo = 0x3f3f3f3f;
template <typename T>
bool chkmax(T &a, const T &b) {
  return a < b ? a = b, 1 : 0;
}
template <typename T>
bool chkmin(T &a, const T &b) {
  return a > b ? a = b, 1 : 0;
}
const int maxn = 100;
int n;
pair<int, int> a[maxn + 5], b[(maxn << 1) + 5];
int dp[2][(maxn << 1) + 5][(maxn << 1) + 5][(maxn << 1) + 5];
int ans = 0;
inline void init() {
  scanf("%d", &n);
  for (int i = (0), _end_ = (n); i < _end_; ++i)
    scanf("%d%d", &a[i].first, &a[i].second);
}
inline void extend(const int &i, const int &cur, const int &nxt, const int &j,
                   const int &k, const int &k0) {
  int l = b[i].first, r = b[i].second;
  if ((j == n << 1 || l > b[j].first) && (l < b[k].first || r > b[k0].second)) {
    if (k0 == n << 1 || l >= b[k0].second) {
      chkmax(dp[nxt][k0][i][i], dp[cur][j][k][k0] + r - l);
    } else {
      int tmp = dp[cur][j][k][k0];
      int newk = k;
      if (l < b[k].first) newk = i, tmp += b[k].first - max(l, b[j].second);
      int newk0 = k0;
      if (r > b[k0].second) newk0 = i, tmp += r - b[k0].second;
      chkmax(dp[nxt][j][newk][newk0], tmp);
    }
  }
}
inline void solve() {
  sort(a, a + n);
  for (int i = (0), _end_ = (n); i < _end_; ++i)
    b[i << 1] = make_pair(a[i].first - a[i].second, a[i].first),
           b[i << 1 | 1] = make_pair(a[i].first, a[i].first + a[i].second);
  b[n << 1].first = oo;
  b[n << 1].second = -oo;
  memset(dp, -oo, sizeof dp);
  dp[0][n << 1][n << 1][n << 1] = 0;
  for (int i = (0), _end_ = (n); i < _end_; ++i) {
    int cur = i & 1, nxt = !cur;
    for (int j = (0), _end_ = (n << 1 | 1); j < _end_; ++j)
      for (int k = (0), _end_ = (n << 1 | 1); k < _end_; ++k)
        for (int k0 = (0), _end_ = (n << 1 | 1); k0 < _end_; ++k0)
          if (dp[cur][j][k][k0] >= 0) {
            extend(i << 1, cur, nxt, j, k, k0);
            extend(i << 1 | 1, cur, nxt, j, k, k0);
            chkmax(dp[nxt][j][k][k0], dp[cur][j][k][k0]);
          }
  }
  ans = 0;
  for (int j = (0), _end_ = (n << 1 | 1); j < _end_; ++j)
    for (int k = (0), _end_ = (n << 1 | 1); k < _end_; ++k)
      for (int k0 = (0), _end_ = (n << 1 | 1); k0 < _end_; ++k0)
        chkmax(ans, dp[n & 1][j][k][k0]);
}
inline void output() { printf("%d\n", ans); }
int main() {
  init();
  solve();
  output();
  return 0;
}
