#include <bits/stdc++.h>   using namespace std;   long long f[105][105][2];   struct seg {     int a;     long long len;     bool operator<(const seg &p) const { return a < p.a; }   } a[105];   int main() {     int n;     scanf( %d , &n);     for (int i = 1; i <= n; ++i) {       scanf( %d%lld , &a[i].a, &a[i].len);     }     sort(a + 1, a + n + 1);     long long ans = 0;     a[0].a = -2e9;     for (int i = 0; i <= n; ++i)       for (int j = 0; j <= i; ++j) {         for (int k = 0; k <= 1; ++k) {           ans = max(ans, f[i][j][k]);           int pr = a[j].a + k * a[j].len;           int R, x;           for (int p = i + 1, mx = -2e9; p <= n; ++p) {             for (int q = 0; q <= 1; ++q) {               int r = a[p].a + q * a[p].len;               if (r > mx) mx = r, R = p, x = q;               f[p][R][x] =                   max(f[p][R][x],                       f[i][j][k] + min(a[p].len, (long long)r - pr) + (mx - r));             }           }         }       }     printf( %lld n , ans);     return 0;   }   