#include <bits/stdc++.h>
using namespace std;
const int N = 330, INF = 1000010000;
int n, m, u, x, y, z, I, ans;
int r[N], l[N], X[N], W[N], a[N], b[N], f[N], g[N][N], h[N][N];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &X[i], &W[i]);
    b[++m] = X[i], b[++m] = X[i] + W[i];
    b[++m] = X[i] - W[i];
  }
  sort(b + 1, b + m + 1);
  m = unique(b + 1, b + m + 1) - b - 1;
  for (int i = 1; i <= n; i++) {
    r[i] = lower_bound(b + 1, b + m + 1, X[i] + W[i]) - b;
    l[i] = lower_bound(b + 1, b + m + 1, X[i] - W[i]) - b;
    a[X[i] = lower_bound(b + 1, b + m + 1, X[i]) - b] = i;
  }
  for (int i = 1; i <= m; i++) {
    int L = i;
    for (int j = i; j <= m; j++) {
      h[i][j] = L;
      g[i][j] = L == i ? i : g[L][j];
      if (a[j]) L = min(L, l[a[j]]);
    }
  }
  for (int i = 1; i <= m; i++) {
    f[i] = f[i - 1];
    for (int j = 1; j <= i - 1; j++)
      if (r[a[j]] >= i) {
        if (j < i - 1 && h[j + 1][i] < j) {
          int x = g[h[j + 1][i]][j];
          f[i] = (f[i] > (f[x] + b[i] - b[x]) ? f[i] : (f[x] + b[i] - b[x]));
        } else
          f[i] = (f[i] > (f[j] + b[i] - b[j]) ? f[i] : (f[j] + b[i] - b[j]));
      }
    if (u = a[i - 1])
      f[i] = (f[i] > (f[g[l[u]][i]] + b[i - 1] - b[g[l[u]][i]])
                  ? f[i]
                  : (f[g[l[u]][i]] + b[i - 1] - b[g[l[u]][i]]));
  }
  cout << f[m] << '\n';
}
