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

typedef long long ll;
int brute(vector<pair<int, int>> v){
  int n = v.size();
  vector<int> p;
  for(int i = 0;i < n;i++)
    p.push_back(i);
  int ans = 0;
  do{
  int res = 0;
    int cur_pos = 0;
    for(int i = 0;i < n;i++){
      if(cur_pos > v[p[i]].second){
        res += cur_pos - v[p[i]].second;
        cur_pos = v[p[i]].second;
      }else if(cur_pos < v[p[i]].first){
        res += v[p[i]].first - cur_pos;
        cur_pos = v[p[i]].first;
      }
    }
    res += abs(cur_pos);
    ans = max(ans, res);
  }while(next_permutation(p.begin(), p.end()));
  return ans;
}
int visitFirst(multiset<int> fir[], multiset<int> sec[], multiset<int>& availFirst, multiset<int>& availSecond, int val, int cur){
//  return 0;
  int offset = 100000;
  int curFirst = val;
  int curSecond = *sec[curFirst + offset].begin();
  fir[curSecond + offset].erase(fir[curSecond + offset].find(curFirst));
  sec[curFirst + offset].erase(sec[curFirst + offset].find(curSecond));
  availFirst.erase(availFirst.find(curFirst));
  availSecond.erase(availSecond.find(curSecond));
  if(curSecond < cur)
    return curSecond;
  if(curFirst > cur)
    return curFirst;
  return cur;

}
int visitSecond(multiset<int> fir[], multiset<int> sec[], multiset<int>& availFirst, multiset<int>& availSecond, int val, int cur){
//  return 0;
  int offset = 100000;
  int curSecond = val;
  int curFirst = *fir[curSecond + offset].rbegin();
  fir[curSecond + offset].erase(fir[curSecond + offset].find(curFirst));
  sec[curFirst + offset].erase(sec[curFirst + offset].find(curSecond));
  availFirst.erase(availFirst.find(curFirst));
  availSecond.erase(availSecond.find(curSecond));
  if(curSecond < cur)
    return curSecond;
  if(curFirst > cur)
    return curFirst;
  return cur;

}
multiset<int> fir[200001];
multiset<int> sec[200001];
multiset<int> availFirst;
multiset<int> availSecond;
ll solve1(vector<pair<int, int>> v){
  int n = v.size();
  int offset = 100000;
  for(int i = 0;i < n;i++){
    fir[v[i].second + offset].insert(v[i].first);
    sec[v[i].first + offset].insert(v[i].second);
    availFirst.insert(v[i].first);
    availSecond.insert(v[i].second);
  }
  int curPos = 0;
  ll res = 0;
  for(int i = 0;i < n;i += 2){
    int toFirst = *availFirst.rbegin();
    int newPos = visitFirst(fir, sec, availFirst, availSecond, toFirst, curPos);
    res += abs(newPos - curPos);
    curPos = newPos;
    if(i + 1 < n){
      int toSecond = *availSecond.begin();
      int newPos = visitSecond(fir, sec, availFirst, availSecond, toSecond, curPos);
      res += abs(newPos - curPos);
      curPos = newPos;
    }
  }
  return res + abs(curPos);
}
ll solve2(vector<pair<int, int>> v){
  int n = v.size();
  int offset = 100000;
  assert(availFirst.empty());
  for(int i = 0;i < n;i++){
    fir[v[i].second + offset].insert(v[i].first);
    sec[v[i].first + offset].insert(v[i].second);
    availFirst.insert(v[i].first);
    availSecond.insert(v[i].second);
  }
  int curPos = 0;
  ll res = 0;
  for(int i = 0;i < n;i += 2){
    int toSecond = *availSecond.begin();
    int newPos = visitSecond(fir, sec, availFirst, availSecond, toSecond, curPos);
    res += abs(newPos - curPos);
    curPos = newPos;
    if(i + 1 < n){
      int toFirst = *availFirst.rbegin();
      int newPos = visitFirst(fir, sec, availFirst, availSecond, toFirst, curPos);
      res += abs(newPos - curPos);
      curPos = newPos;
    }
  }
  return res + abs(curPos);
}
int main()
{
//  freopen("in.txt", "r", stdin);
//  freopen("out.txt", "w", stdout);
  int n;
  cin >> n;
  vector<pair<int, int>> v(n);
  for(int i = 0;i < n;i++){
    cin >> v[i].first >> v[i].second;
  }
//  return 0;
  cout << max(solve2(v), solve1(v));

  return 0;
}


Measured memory_bytes: 40064