#include <bits/stdc++.h>
using namespace std;
long long int powmod(long long int a, int b, int n) {
  long long int rm = 1;
  while (b) {
    if (b % 2) {
      rm = (rm * a) % n;
    }
    a = (a * a) % n;
    b /= 2;
  }
  return rm;
}
int ind[400][400] = {0}, Id[500], Id2[500], t = 0, dis[1000], dp[1000], n,
    Ss[1000], nind[500][500] = {0};
vector<pair<int, int> > v;
bool poss(int p1, int p2, int i1, int i2, int cd) {
  if (p1 == p2) return true;
  if (cd) p2--;
  int sti = -1, fi;
  for (int k = 1; k <= n; ++k) {
    if (v[k].first >= p1) {
      sti = k;
      break;
    }
  }
  if (sti == -1) return false;
  if (v[sti].first > p2) return false;
  for (int k = n; k >= 1; k--) {
    if (v[k].first <= p2) {
      fi = k;
      break;
    }
  }
  if (cd) p2++;
  int mn = p2, tmn;
  if (p2 == v[fi].first) mn = v[fi].first - v[fi].second;
  if (mn <= p1) return true;
  for (int i = fi; i >= sti; i--) {
    if (v[i].first + v[i].second >= p2) {
      tmn = mn;
      mn = min(mn, v[i].first);
      for (int k = Id[i]; k > 0; k--) {
        if (mn == dis[k]) {
          if (k == Id[i]) {
            if (nind[i1][k]) return true;
          } else {
            if (ind[i1][k]) return true;
          }
          break;
        }
        if (Ss[k] && k != Id[i]) {
          mn = min(mn, v[Id2[k]].first - v[Id2[k]].second);
        }
        if (mn <= p1) return true;
      }
      mn = tmn;
    }
    mn = min(mn, v[i].first - v[i].second);
  }
  return false;
}
int main() {
  map<int, int> hash, id1;
  int a, l;
  cin >> n;
  v.push_back(make_pair(0, 0));
  for (int i = int(1); i <= (int)n; i++) {
    cin >> a >> l;
    v.push_back(make_pair(a, l));
    if (!hash[a]) {
      dis[++t] = a;
      hash[a] = 1;
    }
    if (!hash[a + l]) {
      dis[++t] = a + l;
      hash[dis[t]] = 1;
    }
    if (!hash[a - l]) {
      dis[++t] = a - l;
      hash[dis[t]] = 1;
    }
  }
  sort(v.begin() + 1, v.end());
  for (int i = int(1); i <= (int)n; i++) hash[v[i].first] = 2;
  sort(dis + 1, dis + t + 1);
  for (int i = 1; i <= t; ++i) {
    if (hash[dis[i]] == 2) Ss[i] = 1;
    id1[dis[i]] = i;
  }
  for (int i = 1; i <= n; ++i) {
    Id[i] = id1[v[i].first];
    Id2[Id[i]] = i;
  }
  for (int i = 1; i <= t; ++i) {
    for (int j = i; j <= t; ++j) {
      if (poss(dis[i], dis[j], i, j, 0) == 1) {
        ind[i][j] = 1;
      }
      if (!ind[i][j] || !Ss[j]) {
        nind[i][j] = ind[i][j];
      } else {
        nind[i][j] = (poss(dis[i], dis[j], i, j, 1) == true);
      }
    }
  }
  dp[0] = 0;
  for (int i = 1; i <= t; ++i) {
    dp[i] = dp[i - 1];
    for (int j = i; j >= 1; j--) {
      if (ind[j][i] == 1) {
        dp[i] = max(dp[i], dp[j - 1] + dis[i] - dis[j]);
      }
    }
  }
  printf("%d\n", dp[t]);
  return 0;
}
