#include <bits/stdc++.h>
using namespace std;
const int N = 310;
map<int, int> mp;
int a[N], b[N], rev[N];
int dp[N][N];
int id[N];
int rak[N];
bool cmp(int first, int second) { return a[first] < a[second]; }
void update(int &first, int second) { first = max(first, second); }
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i] >> b[i];
    mp[a[i]] = 1;
    mp[a[i] - b[i]] = 1;
    mp[a[i] + b[i]] = 1;
    rak[i] = i;
  }
  int m = 0;
  for (map<int, int>::iterator it = mp.begin(); it != mp.end(); it++) {
    it->second = ++m;
    rev[m] = it->first;
  }
  for (int i = 1; i <= n; i++) id[mp[a[i]]] = i;
  sort(rak + 1, rak + n + 1, cmp);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) dp[i][j] = dp[i - 1][j];
    int p = mp[a[rak[i]]];
    int l = mp[a[rak[i]] - b[rak[i]]];
    int r = mp[a[rak[i]] + b[rak[i]]];
    for (int j = l + 1; j <= p; j++)
      update(dp[i][j], dp[i][j - 1] + rev[j] - rev[j - 1]);
    int t = dp[i - 1][p];
    for (int j = p + 1; j <= r; j++) {
      update(dp[i][j], t + rev[j] - rev[p]);
      if (id[j] && a[id[j]] - b[id[j]] < a[rak[i]])
        t = max(t, dp[i - 1][mp[a[id[j]] - b[id[j]]]] + rev[p] -
                       rev[mp[a[id[j]] - b[id[j]]]]);
    }
    for (int j = 1; j <= m; j++) update(dp[i][j], dp[i][j - 1]);
  }
  cout << dp[n][m] << endl;
  return 0;
}
