#include <iostream>
#include <fstream>
#include <iomanip>
#include <climits>
#include <limits>
#include <algorithm>
#include <array>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <unordered_map>
#include <random>
#include <cmath>
#include <complex>

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

const int INFL = (int)1e9;
const ll INFLL = (ll)1e18;
const double INFD = numeric_limits<double>::infinity();
const double PI = 3.14159265358979323846;
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loopll(i, n) for(ll i = 0; i < (ll)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopll1(i, n) for(ll i = 1; i <= (ll)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Looprll(i, n) for(ll i = (ll)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
#define Looprll1(i, n) for(ll i = (ll)n; i >= 1; i--)
#define Loopitr(itr, container) for(auto itr = container.begin(); itr != container.end(); itr++)
#define printv(vector) Loop(i, vector.size()) { cout << vector[i] << " "; } cout << endl;
#define printmx(matrix) Loop(i, matrix.size()) { Loop(j, matrix[i].size()) { cout << matrix[i][j] << " "; } cout << endl; }
#define rndf(d) (ll)((double)(d) + (d >= 0 ? 0.5 : -0.5))
#define floorsqrt(x) ((ll)sqrt((double)x) + ((ll)sqrt((double)x) * (ll)sqrt((double)x) <= (ll)(x) ? 0 : -1))
#define ceilsqrt(x) ((ll)sqrt((double)x) + ((ll)x <= (ll)sqrt((double)x) * (ll)sqrt((double)x) ? 0 : 1))
#define rnddiv(a, b) ((ll)(a) / (ll)(b) + ((ll)(a) % (ll)(b) * 2 >= (ll)(b) ? 1 : 0))
#define ceildiv(a, b) ((ll)(a) / (ll)(b) + ((ll)(a) % (ll)(b) == 0 ? 0 : 1))
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)

/*******************************************************/

struct val1_t {
	ll id, l, r;
	bool operator<(const val1_t& another) const {
		if (l != another.l) return l < another.l;
		else return id < another.id;
	}
};

struct val2_t {
	ll id, l, r;
	bool operator<(const val2_t& another) const {
		if (r != another.r) return r > another.r;
		else return id > another.id;
	}
};

int main() {
	int n; cin >> n;
	vector<val1_t> val1s(n);
	vector<val2_t> val2s(n);
	Loop(i, n) {
		val1s[i].id = i;
		val2s[i].id = i;
		cin >> val1s[i].l >> val1s[i].r;
		val2s[i].l = val1s[i].l;
		val2s[i].r = val1s[i].r;
	}
	vector<priority_queue<val1_t>> pq1(2);
	vector<priority_queue<val2_t>> pq2(2);
	Loop(i, n) {
		pq1[0].push(val1s[i]);
		pq2[0].push(val2s[i]);
	}
	pq1[1] = pq1[0];
	pq2[1] = pq2[0];
	vector<bool> turn = { true, false };
	vll ans(2, 0);
	vll current_x(2, 0);
	vector<vector<bool>> done(2, vector<bool>(n, false));
	Loop(k, 2) {
		if (turn[k] && pq1[k].top().r < 0) continue;
		if (!turn[k] && pq2[k].top().l > 0) continue;
		Loop(i, n) {
			if (turn[k]) {
				while (true) {
					val1_t focus = pq1[k].top(); pq1[k].pop();
					if (done[k][focus.id]) continue;
					else {
						done[k][focus.id] = true;
						if (current_x[k] < focus.l) {
							ans[k] += focus.l - current_x[k];
							current_x[k] = focus.l;
						}
						break;
					}
				}
			}
			else {
				while (true) {
					val2_t focus = pq2[k].top(); pq2[k].pop();
					if (done[k][focus.id]) continue;
					else {
						done[k][focus.id] = true;
						if (focus.r < current_x[k]) {
							ans[k] += current_x[k] - focus.r;
							current_x[k] = focus.r;
						}
						break;
					}
				}
			}
			turn[k] = !turn[k];
		}
		ans[k] += abs(current_x[k]);
	}
	cout << max(ans[0], ans[1]) << endl;
}

Measured memory_bytes: 15268