#include <bits/stdc++.h>
const long long md = 998244353;
const int Inf = 1e9;
const long long Inf64 = 1e18;
const long long MaxN = 2e5 + 10;
const long long MaxM = 11;
const long double eps = 1e-15;
const long long dx[4] = {0, 1, 0, -1};
const long long dy[4] = {1, 0, -1, 0};
const long long ddx[4] = {1, 1, -1, -1};
const long long ddy[4] = {1, -1, 1, -1};
const long double Pi = acos(-1);
using namespace std;
long long gcd(long long a, long long b) {
  while (a) {
    b %= a;
    swap(a, b);
  }
  return b;
}
long long gcdex(long long a, long long mod = md) {
  long long g = mod, r = a, x = 0, y = 1;
  while (r != 0) {
    long long q = g / r;
    g %= r;
    swap(g, r);
    x -= q * y;
    swap(x, y);
  }
  return x < 0 ? x + mod : x;
}
long long binpow(long long a, long long n) {
  long long res = 1;
  while (n) {
    if (n & 1) {
      res *= a;
      res %= md;
    }
    a *= a;
    a %= md;
    n >>= 1;
  }
  return res % md;
}
bitset<MaxN> A;
bitset<MaxN> B;
long long dst(pair<long long, long long> a, pair<long long, long long> b) {
  return abs(a.first - b.first) + abs(a.second - b.second);
}
long long Mt[MaxN];
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cerr.tie(0);
  cout << fixed, cout.precision(10);
  long long N;
  cin >> N;
  map<long long, vector<pair<long long, long long> > > Mp;
  for (int i = 0; i < N; i++) {
    long long a, b;
    cin >> a >> b;
    Mp[max(a, b)].push_back({a, b});
  }
  Mp[0].push_back({0, -0});
  for (auto& a : Mp) {
    sort(a.second.begin(), a.second.end(),
         [=](pair<long long, long long> a, pair<long long, long long> b) {
           return a.first < b.first ||
                  (a.first == b.first && a.second > b.second);
         });
  }
  vector<vector<long long> > dp(Mp.size() + 1, vector<long long>(2, Inf64));
  dp[0][1] = dp[0][0] = 0;
  long long lvl = 0;
  long long v = 0;
  for (auto& it : Mp) {
    lvl++;
    pair<long long, long long> l = it.second[0];
    pair<long long, long long> r = it.second.back();
    pair<long long, long long> lstl = Mp[v][0];
    pair<long long, long long> lstr = Mp[v].back();
    dp[lvl][0] = min(dp[lvl][0], dp[lvl - 1][0] + dst(lstl, r) + dst(l, r));
    dp[lvl][0] = min(dp[lvl][0], dp[lvl - 1][1] + dst(lstr, r) + dst(l, r));
    dp[lvl][1] = min(dp[lvl][1], dp[lvl - 1][0] + dst(lstl, l) + dst(l, r));
    dp[lvl][1] = min(dp[lvl][1], dp[lvl - 1][1] + dst(lstr, l) + dst(l, r));
    v = it.first;
  }
  cout << min(dp[lvl][0], dp[lvl][1]) << '\n';
  cerr << '\n'
       << "Time execute: " << clock() / (double)CLOCKS_PER_SEC << " sec"
       << '\n';
  return 0;
}
