#include <bits/stdc++.h>
using namespace std;
int N;
struct Node {
  int a, len, l, r;
  Node(int a = 0, int len = 0, int l = 0, int r = 0)
      : a(a), len(len), l(l), r(r) {}
  bool operator<(const Node& n1) const { return a < n1.a; }
} n[305];
int c[305];
int dp[305][305];
int main() {
  cin >> N;
  int top = 0;
  for (int i = 1; i <= N; i++) {
    cin >> n[i].a >> n[i].len;
    n[i].l = n[i].a - n[i].len;
    n[i].r = n[i].a + n[i].len;
    c[++top] = n[i].a;
    c[++top] = n[i].l;
    c[++top] = n[i].r;
  }
  sort(c + 1, c + 1 + top);
  top = unique(c + 1, c + 1 + top) - c - 1;
  for (int i = 1; i <= top; i++) {
  }
  for (int i = 1; i <= N; i++) {
    n[i].a = lower_bound(c + 1, c + 1 + top, n[i].a) - c;
    n[i].l = lower_bound(c + 1, c + 1 + top, n[i].l) - c;
    n[i].r = lower_bound(c + 1, c + 1 + top, n[i].r) - c;
  }
  sort(n + 1, n + 1 + N);
  int a, l, r;
  for (int i = 1; i <= N; i++) {
    a = n[i].a;
    l = n[i].l;
    r = n[i].r;
    for (int j = a; j <= r; j++) {
      dp[i][j] = max(dp[i][j], dp[i - 1][a] + (c[j] - c[a]));
    }
    int rmax = a;
    for (int k = i - 1; k >= 1; k--) {
      rmax = max(rmax, n[k].r);
      for (int j = a; j <= rmax; j++) {
        dp[i][j] = max(dp[i][j], dp[k - 1][l] + (c[j] - c[l]));
      }
    }
    for (int j = a; j > l; j--) {
      dp[i][j] = max(dp[i][j], dp[i - 1][l] + (c[j] - c[l]));
    }
    for (int j = 1; j <= top; j++) {
      dp[i][j] = max(dp[i][j], dp[i][j - 1]);
      dp[i][j] = max(dp[i][j], dp[i - 1][j]);
    }
  }
  cout << dp[N][top] << endl;
  return 0;
}
