#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int res = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -f;
    ch = getchar();
  }
  while (isdigit(ch)) {
    res = res * 10 + ch - '0';
    ch = getchar();
  }
  return res * f;
}
namespace qiqi {
const int N = 105, INF = 0x3f3f3f3f;
int n, f[N][N][2];
pair<int, int> a[N];
void main() {
  int ans = 0;
  n = read();
  for (int i = (1); i <= (n); ++i) {
    a[i].first = read();
    a[i].second = read();
  }
  sort(a + 1, a + n + 1);
  a[0].first = -INF;
  for (int i = (0); i <= (n); ++i)
    for (int j = (0); j <= (i); ++j)
      for (int p = (0); p <= (1); ++p) {
        ans = max(ans, f[i][j][p]);
        int v = a[j].first + p * a[j].second, mx = -INF, c, x, y;
        for (int k = (i + 1); k <= (n); ++k)
          for (int q = (0); q <= (1); ++q) {
            c = a[k].first + q * a[k].second;
            if (c > mx) {
              mx = c;
              x = k;
              y = q;
            }
            f[k][x][y] =
                max(f[k][x][y], f[i][j][p] + min(a[k].second, c - v) + mx - c);
          }
      }
  printf("%d\n", ans);
}
}  // namespace qiqi
int main() {
  qiqi::main();
  return 0;
}
