#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
int n, m, k;
pair<int, int> a[maxn];
bool cmp(pair<int, int>& x, pair<int, int>& y) {
  if (max(x.first, x.second) != max(y.first, y.second))
    return max(x.first, x.second) < max(y.first, y.second);
  return x.second < y.second || x.second == y.second && x.first > y.first;
}
bool cmp1(pair<int, int>& x, pair<int, int>& y) {
  if (max(x.first, x.second) != max(y.first, y.second))
    return max(x.first, x.second) < max(y.first, y.second);
  return x.first < y.first || x.first == y.first && x.second > y.second;
}
vector<pair<int, int>> v[maxn];
long long dp[maxn][2];
pair<int, int> Mina[maxn], Minb[maxn];
long long dis(pair<int, int> x, pair<int, int> y) {
  return abs(x.first - y.first) + abs(x.second - y.second);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  if (fopen(""
            ".INP",
            "r"))
    freopen(
        ""
        ".INP",
        "r", stdin),
        freopen(
            ""
            ".OUT",
            "w", stdout);
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i].first >> a[i].second;
  sort(a + 1, a + n + 1, cmp);
  int sz = 0;
  for (int i = 1; i <= n; ++i) {
    if (max(a[i].first, a[i].second) != max(a[i - 1].first, a[i - 1].second))
      ++sz;
    v[sz].push_back(a[i]);
  }
  for (int i = 1; i <= sz; ++i) {
    sort(v[i].begin(), v[i].end(), cmp);
    Mina[i] = v[i][0];
    sort(v[i].begin(), v[i].end(), cmp1);
    Minb[i] = v[i][0];
    dp[i][0] = min(dp[i - 1][0] + dis(Mina[i - 1], Minb[i]),
                   dp[i - 1][1] + dis(Minb[i - 1], Minb[i])) +
               dis(Mina[i], Minb[i]);
    dp[i][1] = min(dp[i - 1][0] + dis(Mina[i - 1], Mina[i]),
                   dp[i - 1][1] + dis(Minb[i - 1], Mina[i])) +
               dis(Mina[i], Minb[i]);
  }
  cout << min(dp[sz][0], dp[sz][1]);
}
