#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 5, Mod = 1e9 + 7;
pair<long long, long long> Cl[N], Cr[N];
long long Dp[N][2], X[N], Y[N], n;
vector<long long> T;
long long DIS(pair<long long, long long> a, pair<long long, long long> b,
              pair<long long, long long> c) {
  return abs(a.first - b.first) + abs(b.first - c.first) +
         abs(a.second - b.second) + abs(b.second - c.second);
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> X[i] >> Y[i];
    T.push_back(max(X[i], Y[i]));
  }
  sort(T.begin(), T.end());
  T.resize(unique(T.begin(), T.end()) - T.begin());
  for (long long i = 0; i < (long long)T.size(); i++)
    Cl[i] = Cr[i] = make_pair(Mod, Mod);
  for (long long i = 1; i <= n; i++) {
    long long id = lower_bound(T.begin(), T.end(), max(X[i], Y[i])) - T.begin();
    Cl[id] = min(Cl[id], make_pair(X[i], -Y[i]));
    Cr[id] = min(Cr[id], make_pair(Y[i], -X[i]));
  }
  for (long long i = 0; i < (long long)T.size(); i++)
    swap(Cr[i].first, Cr[i].second), Cl[i].second = -Cl[i].second,
                                     Cr[i].first = -Cr[i].first;
  ;
  Dp[0][0] = DIS(make_pair(0, 0), Cr[0], Cl[0]);
  Dp[0][1] = DIS(make_pair(0, 0), Cl[0], Cr[0]);
  long long Ans = min(Dp[0][0], Dp[0][1]);
  for (long long i = 1; i < (long long)T.size(); i++) {
    Dp[i][0] = min(Dp[i - 1][0] + DIS(Cl[i - 1], Cr[i], Cl[i]),
                   Dp[i - 1][1] + DIS(Cr[i - 1], Cr[i], Cl[i]));
    Dp[i][1] = min(Dp[i - 1][0] + DIS(Cl[i - 1], Cl[i], Cr[i]),
                   Dp[i - 1][1] + DIS(Cr[i - 1], Cl[i], Cr[i]));
    Ans = min(Dp[i][0], Dp[i][1]);
  }
  cout << Ans;
  return 0;
}
