#include <bits/stdc++.h>
using namespace std;
int dp[505][1005];
vector<pair<int, int> > fakelights;
map<int, int> comp;
map<int, int> compress;
unordered_map<int, int> backcompress;
int cnt = 1;
struct Light {
  int left;
  int pos;
  int right;
  Light() {}
  Light(int a, int b, int c) {
    left = a;
    pos = b;
    right = c;
  }
};
vector<Light> lights;
int computeforward(int l) {
  int k = 0;
  int ans = 0;
  for (int g = l; g < lights.size(); g++) {
    if (backcompress[lights[g].pos] > k) k = backcompress[lights[g].pos];
    if (backcompress[lights[g].right] > k) {
      ans += backcompress[lights[g].right] - k;
      k = backcompress[lights[g].right];
    }
  }
  return ans;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int g = 0; g < n; g++) {
    int a, b;
    scanf("%d", &a);
    scanf("%d", &b);
    fakelights.push_back(pair<int, int>(a, b));
  }
  sort(fakelights.begin(), fakelights.end());
  for (int g = 0; g < fakelights.size(); g++)
    comp[fakelights[g].first] = 1,
    comp[fakelights[g].first + fakelights[g].second] = 1,
    comp[fakelights[g].first - fakelights[g].second] = 1;
  for (auto x = comp.begin(); x != comp.end(); x++) {
    compress[x->first] = cnt;
    backcompress[cnt++] = x->first;
  }
  for (pair<int, int> g : fakelights)
    lights.push_back(Light(compress[g.first - g.second], compress[g.first],
                           compress[g.first + g.second]));
  for (int g = lights.size() - 1; g >= 0; g--) {
    for (int z = 0; z <= cnt; z++) {
      dp[g][z] = computeforward(g);
      for (int y = g; y < lights.size(); y++) {
        int ans = min(
            backcompress[lights[y].pos] -
                ((lights[g].pos - z <= 0) ? (-500000000)
                                          : (backcompress[lights[g].pos - z])),
            backcompress[lights[y].pos] - backcompress[lights[y].left]);
        int x = lights[y].pos;
        for (int t = g; t < y; t++) {
          if (lights[t].right > x) x = lights[t].right;
        }
        int zz = 0;
        for (int t = g; t < y; t++) {
          if (lights[t].pos >= lights[y].left) break;
          if (lights[t].pos > zz) zz = lights[t].pos;
          int L = lights[t].right;
          if (L >= lights[y].left) L = lights[y].left;
          if (L >= zz) {
            ans += backcompress[L] - backcompress[zz];
            zz = L;
          }
        }
        ans += backcompress[x] - backcompress[lights[y].pos];
        int farthest = x;
        int R = y + 1;
        while (R < lights.size() && lights[R].pos <= farthest) {
          if (lights[R].right >= farthest) {
            ans += backcompress[lights[R].right] - backcompress[farthest];
            farthest = lights[R].right;
          }
          R++;
        }
        if (R != lights.size()) ans += dp[R][lights[R].pos - farthest];
        if (ans > dp[g][z]) dp[g][z] = ans;
      }
    }
  }
  cout << dp[0][cnt] << '\n';
  return 0;
}
