#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e2 + 10;
int dp[maxn][maxn][2];
pair<int, int> p[maxn];
int ans = 0, n;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d%d", &p[i].first, &p[i].second);
  sort(p + 1, p + 1 + n), p[0].first = -1e9;
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= i; j++)
      for (int o = 0; o <= 1; o++) {
        ans = max(ans, dp[i][j][o]);
        int mx = -1e9, po, q;
        int lst = p[j].first + p[j].second * o;
        for (int k = i + 1; k <= n; k++)
          for (int t = 0; t <= 1; t++) {
            int cur = p[k].first + p[k].second * t;
            if (cur > mx) mx = cur, po = k, q = t;
            dp[k][po][q] =
                max(dp[k][po][q],
                    dp[i][j][o] + min(cur - lst, p[k].second) + mx - cur);
          }
      }
  printf("%d\n", ans);
}
