#include <bits/stdc++.h>
using namespace std;
long long ksm(long long a, long long b) {
  if (!b) return 1;
  long long ns = ksm(a, b >> 1);
  ns = ns * ns % 998244353;
  if (b & 1) ns = ns * a % 998244353;
  return ns;
}
int tr[305];
vector<int> sr;
int dp[305][305];
pair<int, int> th[305];
int gt(int pl) { return lower_bound(sr.begin(), sr.end(), pl) - sr.begin(); }
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++)
    scanf("%d%d", &th[i].first, &th[i].second),
        sr.push_back(th[i].first + th[i].second),
        sr.push_back(th[i].first - th[i].second), sr.push_back(th[i].first);
  sort(th + 1, th + n + 1);
  sort(sr.begin(), sr.end());
  for (int i = 0; i <= n; i++)
    for (int j = 0; j < sr.size(); j++) {
      if (i == 0)
        dp[i][j] = 0;
      else {
        int nx = gt(th[i].first - th[i].second);
        int ndis = max(0, min(sr[j], th[i].first) - sr[nx]);
        dp[i][j] = max(dp[i][j], ndis + dp[i - 1][min(nx, j)]);
        int mn = j;
        for (int k = i; k >= 1; k--) {
          int us = min(mn, gt(th[k].first));
          int ndis = max(0, min(sr[j], th[k].first + th[k].second) - sr[us]);
          dp[i][j] = max(dp[i][j], ndis + dp[k - 1][us]);
          mn = min(mn, gt(th[k].first - th[k].second));
        }
      }
    }
  cout << dp[n][sr.size() - 1] << endl;
  return 0;
}
