#include <bits/stdc++.h>
using namespace std;
inline int read() {
  char ch = getchar();
  int w = 1, c = 0;
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') w = -1;
  for (; isdigit(ch); ch = getchar()) c = (c << 1) + (c << 3) + (ch ^ 48);
  return w * c;
}
const int M = 500;
struct node {
  int p, l;
} a[M];
bool cmp(node A, node B) { return A.p < B.p; }
int dp[M][M][2], n;
int main() {
  n = read();
  for (int i = (1); i <= (n); ++i) a[i] = node{read(), read()};
  sort(a + 1, a + n + 1, cmp);
  a[0] = node{-(1 << 29), 0};
  int ans = 0;
  for (int i = (0); i <= (n); ++i) {
    for (int j = (0); j <= (i); ++j) {
      for (int t = (0); t <= (1); ++t) {
        if (ans < dp[i][j][t]) ans = dp[i][j][t];
        int L = a[j].p + t * a[j].l;
        int R = -1, ff, op;
        for (int k = (i + 1); k <= (n); ++k) {
          for (int o = (0); o <= (1); ++o) {
            int tmp = a[k].p + o * a[k].l;
            if (tmp > R) R = tmp, ff = k, op = o;
            dp[k][ff][op] = max(dp[k][ff][op],
                                dp[i][j][t] + min(tmp - L, a[k].l) + R - tmp);
          }
        }
      }
    }
  }
  cout << ans << "\n";
  return 0;
}
