#include <bits/stdc++.h>
using namespace std;
const int MAXN = 105;
int f[MAXN][MAXN][2];
int N;
pair<int, int> data[MAXN];
int main() {
  cin >> N;
  for (int i = 1; i <= N; ++i) {
    cin >> data[i].first >> data[i].second;
  }
  sort(data + 1, data + N + 1);
  data[0].first = -1e9;
  int ans = 0;
  for (int i = 0; i <= N; ++i)
    for (int j = 0; j <= i; ++j)
      for (int k = 0; k < 2; ++k) {
        int r = data[j].first + k * data[j].second;
        int v = f[i][j][k];
        ans = max(ans, v);
        int mj = 0, mk = 0;
        int mr = -1;
        for (int tj = i + 1; tj <= N; ++tj)
          for (int tk = 0; tk < 2; ++tk) {
            int tr = data[tj].first + tk * data[tj].second;
            if (tr > mr) {
              mr = tr;
              mj = tj;
              mk = tk;
            }
            int tv = v + min(data[tj].second, tr - r) + mr - tr;
            f[tj][mj][mk] = max(f[tj][mj][mk], tv);
          }
      }
  cout << ans << endl;
}
