#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 9;
int m;
inline void add(int& a, int b) {
  a += b;
  if (a >= m) a -= m;
}
pair<long long, long long> a[N];
long long dp[2][2];
map<long long, vector<pair<long long, long long>>> lev;
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i].first >> a[i].second;
    lev[max(a[i].first, a[i].second)].push_back({a[i].first, a[i].second});
  }
  pair<long long, long long> mnx, mny, lmnx, lmny;
  long long now = 0;
  lmnx = lmny = {0, 0};
  for (auto it : lev) {
    mnx = mny = {1000000007, 1000000007};
    for (auto it1 : it.second) {
      if (it1.first < mnx.first ||
          it1.first == mnx.first && it1.second > mnx.second) {
        mnx = it1;
      }
      if (it1.second < mny.second ||
          it1.second == mny.second && it1.first > mny.first) {
        mny = it1;
      }
    }
    now ^= 1;
    long long ext = abs(mny.first - mnx.first) + abs(mnx.second - mny.second);
    dp[now][0] = min(dp[now ^ 1][1] + abs(mny.first - lmny.first) +
                         abs(mny.second - lmny.second),
                     dp[now ^ 1][0] + abs(mny.first - lmnx.first) +
                         abs(mny.second - lmnx.second)) +
                 ext;
    dp[now][1] = min(dp[now ^ 1][0] + abs(mnx.first - lmnx.first) +
                         abs(mnx.second - lmnx.second),
                     dp[now ^ 1][1] + abs(mnx.first - lmny.first) +
                         abs(mnx.second - lmny.second)) +
                 ext;
    lmnx = mnx;
    lmny = mny;
  }
  cout << min(dp[now][0], dp[now][1]) << endl;
  return 0;
}
