#include <bits/stdc++.h>
using namespace std;

#define all(x) begin(x), end(x)
#define sz(x) (ll)(x).size()

using ll = long long;
using ld = long double;

constexpr ll inf = 1000000000000000000;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	ll n;
	cin >> n;
	vector<pair<ll, ll>> in(n);
	for (ll i = 0; i < n; i++) {
		ll t, x;
		cin >> t >> x;
		in[i] = {t, x};
	}
	sort(all(in));
	auto ok = [&](ll m){
		ll l = -inf;
		ll r = inf;
		ll lastT = 0;
		for (auto e : in) {
			ll dt = e.first - lastT;
			r = min(r + dt, e.second);
			l = max(l - dt, e.second-m);
			assert(r >= l);
			lastT = e.first;
		}
		return m-(r-l);
	};
	cout << ok(inf) << endl;
}
 