#include <bits/stdc++.h>
using namespace std;
long long read() {
  long long x = 0, f = 0;
  char ch = getchar();
  while (!isdigit(ch)) f = ch == '-', ch = getchar();
  while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
  return f ? -x : x;
}
const int N = 105, INF = 1e9;
int n;
pair<int, int> a[N];
int dp[N][N][2];
void ckmax(int &a, int b) {
  if (a < b) a = b;
}
int main() {
  n = read();
  for (int i = (1); i <= (n); i++) a[i].first = read(), a[i].second = read();
  sort(a + 1, a + n + 1);
  for (int i = (0); i <= (N - 1); i++)
    for (int j = (0); j <= (N - 1); j++)
      for (int k = (0); k <= (1); k++) dp[i][j][k] = -INF;
  a[0].first = -INF, a[0].second = 0;
  dp[0][0][0] = 0;
  int ans = -INF;
  for (int i = (0); i <= (n - 1); i++)
    for (int j = (0); j <= (i); j++)
      for (int k = (0); k <= (1); k++) {
        int v = dp[i][j][k];
        if (v == -INF) continue;
        int rp = a[j].first + k * a[j].second;
        {
          int tmp = v, R = rp;
          for (int t = (i + 1); t <= (n); t++) {
            if (a[t].first + a[t].second <= R) continue;
            tmp += a[t].first + a[t].second - max(R, a[t].first);
            R = a[t].first + a[t].second;
          }
          ckmax(ans, tmp);
        }
        pair<int, int> R = make_pair(j, k);
        for (int t = (i + 1); t <= (n - 1); t++) {
          int p = a[t].first - a[t].second;
          if (a[R.first].first + R.second * a[R.first].second <= a[t].first)
            R = make_pair(t, 0);
          if (p <= rp)
            ckmax(dp[t][R.first][R.second],
                  v + (a[R.first].first + R.second * a[R.first].second - rp));
          else {
            int id = i + 1;
            while (id < t && a[id].first + a[id].second <= rp) id++;
            int RR = rp, tmp = v;
            for (int x = (id); x <= (t - 1); x++) {
              if (a[x].first >= p) break;
              if (a[x].first + a[x].second <= RR) continue;
              tmp += a[x].first + a[x].second - max(RR, a[x].first);
              RR = a[x].first + a[x].second;
            }
            tmp += a[R.first].first + R.second * a[R.first].second - max(RR, p);
            ckmax(dp[t][R.first][R.second], tmp);
          }
          if (a[R.first].first + R.second * a[R.first].second <=
              a[t].first + a[t].second)
            R = make_pair(t, 1);
        }
      }
  cout << ans << endl;
  return 0;
}
