#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

bool comp1(pair<int, pair<long long, long long> > p1, pair<int, pair<long long, long long> > p2)
{
    return (p1.second.first < p2.second.first);
}

bool comp2(pair<int, pair<long long, long long> > p1, pair<int, pair<long long, long long> > p2)
{
    return (p1.second.second > p2.second.second);
}
int main() {
    //cout.precision(10);
    bool used[100100];
    for(int i = 0; i <= 100010; i++){
        used[i] = false;
    }
    int n;
    cin >> n;
    vector<pair<int, pair<long long, long long> > >v1, v2, v3, v4;
    for(int i = 1; i <= n; i++){
        int in1, in2;
        cin >> in1 >> in2;
        pair<long long, long long> in;
        in.first = in1;
        in.second = in2;
        pair<int, pair<long long, long long> > in3;
        in3.first = i;
        in3.second = in;
        v1.push_back(in3);
        v2.push_back(in3);
        in.first = -in2;
        in.second = -in1;
        in3.second = in;
        v3.push_back(in3);
        v4.push_back(in3);
    }
    long long x = 0;
    long long ans1 = 0;
    long long ans2 = 0;
    sort(v1.begin(), v1.end(), comp1);
    sort(v3.begin(), v3.end(), comp1);
    sort(v2.begin(), v2.end(), comp2);
    sort(v4.begin(), v4.end(), comp2);
    x = v1[v1.size() - 1].second.first;
    ans1 += abs(v1[v1.size() - 1].second.first);
    used[v1[v1.size() - 1].first] = true;
    v1.pop_back();
    for(int i = 1; i < n; i++){
        if(i % 2 == 0){
            while(used[v1[v1.size() - 1].first]){
                v1.pop_back();
            }
            if(x < v1[v1.size() - 1].second.first){
                ans1 += v1[v1.size() - 1].second.first - x;
            }
            x = max(x, v1[v1.size() - 1].second.first);
            used[v1[v1.size() - 1].first] = true;
            v1.pop_back();
            continue;
        }
        while(used[v2[v2.size() - 1].first]){
            v2.pop_back();
        }
        if(x > v2[v2.size() - 1].second.second){
            ans1 += x - v2[v2.size() - 1].second.second;
        }
        x = min(x, v2[v2.size() - 1].second.second);
        used[v2[v2.size() - 1].first] = true;
        v2.pop_back();
    }
    ans1 += abs(x);
    for(int i = 0; i <= 100010; i++){
        used[i] = false;
    }
    x = v3[v3.size() - 1].second.first;
    ans2 += abs(v3[v3.size() - 1].second.first);
    used[v3[v3.size() - 1].first] = true;
    v3.pop_back();
    for(int i = 1; i < n; i++){
        if(i % 2 == 0){
            while(used[v3[v3.size() - 1].first]){
                v3.pop_back();
            }
            if(x < v3[v3.size() - 1].second.first){
                ans2 += v3[v3.size() - 1].second.first - x;
            }
            x = max(x, v3[v3.size() - 1].second.first);
            used[v3[v3.size() - 1].first] = true;
            v3.pop_back();
            continue;
        }
        while(used[v4[v4.size() - 1].first]){
            v4.pop_back();
        }
        if(x > v4[v4.size() - 1].second.second){
            ans2 += x - v4[v4.size() - 1].second.second;
        }
        x = min(x, v4[v4.size() - 1].second.second);
        used[v4[v4.size() - 1].first] = true;
        v4.pop_back();
    }
    ans2 += abs(x);
    cout << max(ans1, ans2) << endl;
    /*for(int i = 0; i < n; i++){
        if(i % 2 == 0){
            sort(v1.begin(), v1.end(), comp1);
            sort(v2.begin(), v2.end(), comp2);
            if(x1 < v1[v1.size() - 1].first){
                ans1 += v1[v1.size() - 1].first - x1;
            }
                x1 = max(x1, v1[v1.size() - 1].first);
            v1.pop_back();
            if(x2 > v2[v2.size() - 1].second){
                ans2 -= v2[v2.size() - 1].second - x2;
            }
                x2 = min(x2, v2[v2.size() - 1].second);
            v2.pop_back();
            continue;
        }
            sort(v1.begin(), v1.end(), comp2);
            sort(v2.begin(), v2.end(), comp1);
            if(x2 < v2[v2.size() - 1].first){
                ans2 += v2[v1.size() - 1].first - x2;
            }
                x2 = max(x2, v2[v2.size() - 1].first);
            v2.pop_back();
            if(x1 > v1[v1.size() - 1].second){
                ans1 -= v1[v1.size() - 1].second - x1;
            }
                x1 = min(x1, v1[v1.size() - 1].second);
            v1.pop_back();
        }
        cout << max(ans2 + abs(x2), ans1 + abs(x1)) << endl;
    */
    return 0;
}

Measured memory_bytes: 12108