#include <bits/stdc++.h>
using namespace std;
template <class T>
T abs(T x) {
  return x > 0 ? x : -x;
}
const int tt = 75;
int n;
int m;
int x[100];
int y[100];
int z[100];
vector<int> v;
vector<int> w[300];
int res[301][301][2];
int was[301][301][2];
map<int, int> num;
int f[300];
int calc() {
  vector<pair<int, int> > v;
  for (int i = 0; i < n; i++)
    if (z[i]) {
      v.push_back(make_pair(x[i], 1));
      v.push_back(make_pair(x[i] + y[i], -1));
    } else {
      v.push_back(make_pair(x[i] - y[i], 1));
      v.push_back(make_pair(x[i], -1));
    }
  sort((v).begin(), (v).end());
  int cur = 0, bal = 0;
  for (int i = 0; i + 1 < 2 * n; i++) {
    bal += v[i].second;
    if (bal) cur += v[i + 1].first - v[i].first;
  }
  return cur;
}
int go(int i, int j, int t) {
  if (j < i) {
    t = 0;
    j = i;
  }
  if (i == ((int)(v).size())) return 0;
  if (was[i][j][t]) return res[i][j][t];
  was[i][j][t] = 1;
  int cur = go(i + 1, j, t);
  if ((!t || i < j) && f[i] > j)
    cur = max(cur, go((t ? j : i) + 1, f[i], 0) + (v[f[i]] - v[j]));
  for (int k = 0; k < ((int)(w[i]).size()); k++)
    if (w[i][k] > j)
      cur = max(cur, go((t ? j : i) + 1, w[i][k], 1) + (v[w[i][k]] - v[j]));
  return res[i][j][t] = cur;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &x[i], &y[i]);
    v.push_back(x[i] - y[i]);
    v.push_back(x[i]);
    v.push_back(x[i] + y[i]);
  }
  sort((v).begin(), (v).end());
  v.resize(unique((v).begin(), (v).end()) - v.begin());
  for (int i = 0; i < ((int)(v).size()); i++) num[v[i]] = i;
  for (int i = 0; i < n; i++) {
    int a = num[x[i] - y[i]];
    int b = num[x[i]];
    int c = num[x[i] + y[i]];
    f[b] = c;
    w[a].push_back(b);
  }
  printf("%d\n", go(0, 0, 0));
  return 0;
}
