#include <bits/stdc++.h>
using namespace std;
struct node {
  int p, l;
} a[300002];
int n, dp[102][102][2];
bool cmp(node n1, node n2) { return n1.p < n2.p; }
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d%d", &a[i].p, &a[i].l);
  sort(a + 1, a + 1 + n, cmp);
  a[0].p = -1e9;
  int ans = 0;
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= i; j++)
      for (int ii = 0; ii < 2; ii++) {
        ans = max(ans, dp[i][j][ii]);
        int mx = -1e9, pos, fx;
        for (int k = i + 1; k <= n; k++) {
          for (int jj = 0; jj < 2; jj++) {
            int ri = a[k].p + jj * a[k].l;
            if (ri > mx) mx = ri, pos = k, fx = jj;
            dp[k][pos][fx] =
                max(dp[k][pos][fx], dp[i][j][ii] + mx - ri +
                                        min(a[k].l, ri - a[j].p - ii * a[j].l));
          }
        }
      }
  printf("%d\n", ans);
}
