#include <bits/stdc++.h>

using namespace std;

int n;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	cin >> n;
	
	vector<int> x(n+1), y(n+1);

	for (int i = 1; i <= n; i++) {
		cin >> x[i] >> y[i];
	}

	sort(x.rbegin(), x.rend());
	sort(y.begin(), y.end());
	
	long long ans = 0;
	for (int i = 0; i <= n; i++) {
		if (x[i] > y[i]) {
			ans += 2 * (x[i] - y[i]);
		}
	}
	cout << ans << endl;

	return 0;
}