#include <bits/stdc++.h>
using namespace std;
const int MAXN = 105;
int dp[MAXN][3 * MAXN][3 * MAXN], lef[MAXN][MAXN][3 * MAXN], b[MAXN][3 * MAXN],
    leftX[MAXN], x[MAXN], rightX[MAXN];
pair<int, int> a[MAXN];
vector<int> v;
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; (i) < (n); ++i) {
    scanf("%d%d", &a[i].first, &a[i].second);
    v.push_back(a[i].first - a[i].second);
    v.push_back(a[i].first);
    v.push_back(a[i].first + a[i].second);
  }
  sort((v).begin(), (v).end());
  v.resize(unique((v).begin(), (v).end()) - v.begin());
  sort(a, a + n);
  int sz = (int)((v).size());
  for (int i = 0; (i) < (n); ++i) {
    leftX[i] = lower_bound((v).begin(), (v).end(), a[i].first - a[i].second) -
               v.begin();
    x[i] = lower_bound((v).begin(), (v).end(), a[i].first) - v.begin();
    rightX[i] = lower_bound((v).begin(), (v).end(), a[i].first + a[i].second) -
                v.begin();
  }
  for (int l = 0; (l) < (n); ++l)
    for (int r = 0; (r) < (n); ++r)
      for (int i = 0; (i) < (sz); ++i) lef[l][r][i] = -1;
  for (int l = 0; (l) < (n); ++l) {
    for (int r = 0; (r) < (n); ++r)
      for (int i = 0; (i) < (sz); ++i)
        for (int j = 0; (j) < (sz); ++j) dp[r][i][j] = -1;
    dp[l][x[l]][x[l]] = leftX[l];
    dp[l][rightX[l]][rightX[l]] = x[l];
    for (int r = (l); (r) < (n - 1); ++r)
      for (int i = 0; (i) < (sz); ++i)
        for (int j = 0; (j) < (sz); ++j)
          if (dp[r][i][j] != -1) {
            int leftEnd = 0, rightEnd = 0, rightLeftEnd = 0;
            leftEnd = min(dp[r][i][j], leftX[r + 1]);
            rightEnd = max(i, x[r + 1]);
            if (leftX[r + 1] > j)
              rightLeftEnd = j;
            else
              rightLeftEnd = rightEnd;
            if (dp[r + 1][rightEnd][rightLeftEnd] == -1 ||
                dp[r + 1][rightEnd][rightLeftEnd] > leftEnd)
              dp[r + 1][rightEnd][rightLeftEnd] = leftEnd;
            leftEnd = min(dp[r][i][j], x[r + 1]);
            rightEnd = max(i, rightX[r + 1]);
            if (x[r + 1] > j)
              rightLeftEnd = j;
            else
              rightLeftEnd = max(rightEnd, rightX[r + 1]);
            if (dp[r + 1][rightEnd][rightLeftEnd] == -1 ||
                dp[r + 1][rightEnd][rightLeftEnd] > leftEnd)
              dp[r + 1][rightEnd][rightLeftEnd] = leftEnd;
          }
    for (int r = (l); (r) < (n); ++r)
      for (int i = 0; (i) < (sz); ++i)
        if (dp[r][i][i] != -1) lef[l][r][i] = dp[r][i][i];
  }
  int ans = 0;
  for (int i = 0; (i) < (n); ++i)
    for (int j = 0; (j) < (sz); ++j) {
      for (int g = 0; (g) < (i); ++g)
        for (int k = 0; (k) < (j); ++k)
          if (lef[g + 1][i][j] > k &&
              b[g][k] + v[j] - v[lef[g + 1][i][j]] > b[i][j])
            b[i][j] = b[g][k] + v[j] - v[lef[g + 1][i][j]];
      for (int g = 0; (g) < (i + 1); ++g)
        if (lef[g][i][j] != -1) b[i][j] = max(b[i][j], v[j] - v[lef[g][i][j]]);
      ans = max(ans, b[i][j]);
    }
  printf("%d\n", ans);
  return 0;
}
