#include <bits/stdc++.h>
using namespace std;
bool Finish_read;
template <class T>
inline void read(T &x) {
  Finish_read = 0;
  x = 0;
  int f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    if (ch == EOF) return;
    ch = getchar();
  }
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
  x *= f;
  Finish_read = 1;
}
template <class T>
inline void print(T x) {
  if (x / 10 != 0) print(x / 10);
  putchar(x % 10 + '0');
}
template <class T>
inline void writeln(T x) {
  if (x < 0) putchar('-');
  x = abs(x);
  print(x);
  putchar('\n');
}
template <class T>
inline void write(T x) {
  if (x < 0) putchar('-');
  x = abs(x);
  print(x);
}
const int N = 305;
struct node {
  long long pos, l;
  bool operator<(const node &rhs) const { return pos < rhs.pos; }
} p[N];
int n, totP;
int Point[N * 3];
long long f[N][N * 3], last[N * 3], Lef[N * 3];
void Init() {
  for (int i = 1; i <= n; i++) {
    int ps = lower_bound(Point + 1, Point + 1 + totP, p[i].pos) - Point;
    last[ps] = i;
    Lef[ps] =
        lower_bound(Point + 1, Point + 1 + totP, p[i].pos - p[i].l) - Point;
  }
}
void Solve() {
  for (int i = 1; i <= n; i++) {
    int now = lower_bound(Point + 1, Point + 1 + totP, p[i].pos) - Point;
    int l = lower_bound(Point + 1, Point + 1 + totP, p[i].pos - p[i].l) - Point;
    int r = lower_bound(Point + 1, Point + 1 + totP, p[i].pos + p[i].l) - Point;
    for (int j = 1; j <= totP; j++) f[i][j] = f[i - 1][j];
    long long nwp = Point[now];
    for (int j = l + 1; j <= now; ++j) {
      f[i][j] = max(f[i][j], f[i][j - 1] + Point[j] - Point[j - 1]);
    }
    long long Mx = f[i - 1][now];
    for (int j = now + 1; j <= r; ++j) {
      f[i][j] = max(f[i][j], Mx + Point[j] - nwp);
      if (last[j] && Lef[j] < now)
        Mx = max(Mx, nwp - Point[Lef[j]] + f[i - 1][Lef[j]]);
    }
    for (int j = 1; j <= totP; j++) {
      f[i][j] = max(f[i][j], f[i][j - 1]);
    }
  }
}
int main() {
  read(n);
  for (int i = 1; i <= n; i++) {
    read(p[i].pos);
    read(p[i].l);
    Point[++totP] = p[i].pos;
    Point[++totP] = p[i].pos - p[i].l;
    Point[++totP] = p[i].pos + p[i].l;
  }
  sort(p + 1, p + 1 + n);
  sort(Point + 1, Point + 1 + totP);
  totP = unique(Point + 1, Point + 1 + totP) - Point - 1;
  Init();
  Solve();
  printf("%lld\n", f[n][totP]);
  return 0;
}
