#include <bits/stdc++.h>
int n;
int a[105], l[105];
int id[105];
int dp[105][105][2];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < (int)(n); ++i) scanf("%d %d", &a[i], &l[i]);
  for (int i = 0; i < (int)(n); ++i) id[i] = i;
  std::sort(id, id + n, [&](int x, int y) { return a[x] < a[y]; });
  dp[0][0][0] = 0;
  for (int i = 0; i < (int)(n); ++i) {
    for (int j = 0; j < (int)(i + 1); ++j) {
      for (int k = 0; k < (int)(2); ++k) {
        int mj = -1, mk = -1;
        for (int nj = i; nj < n; ++nj) {
          for (int nk = 0; nk < (int)(2); ++nk) {
            if (mj == -1 ||
                a[id[mj]] + mk * l[id[mj]] < a[id[nj]] + nk * l[id[nj]])
              mj = nj, mk = nk;
            dp[nj + 1][mj + 1][mk] = std::max(
                dp[nj + 1][mj + 1][mk],
                dp[i][j][k] + a[id[mj]] + mk * l[id[mj]] -
                    std::max(
                        (j ? a[id[j - 1]] + k * l[id[j - 1]] : -0x3f3f3f3f),
                        a[id[nj]] - (!nk) * l[id[nj]]));
          }
        }
      }
    }
  }
  int ans = 0;
  for (int j = 0; j < (int)(n + 1); ++j)
    for (int k = 0; k < (int)(2); ++k) {
      ans = std::max(ans, dp[n][j][k]);
    }
  printf("%d\n", ans);
  return 0;
}
