#include <bits/stdc++.h>
using namespace std;
long long int n;
pair<long long int, long long int> pts[200005];
bool cmp(pair<long long int, long long int> p1,
         pair<long long int, long long int> p2) {
  long long int m1 = max(p1.first, p1.second);
  long long int m2 = max(p2.first, p2.second);
  if (m1 != m2) return m1 < m2;
  if (p1.second == m1 && p2.second == m2) return p1.first < p2.first;
  if (p1.second == m1) return 1;
  if (p2.second == m1) return 0;
  return p1.second > p2.second;
}
long long int dp[200005][7];
pair<long long int, long long int> best[200005][7];
long long int tot;
const long long int inf = 1e16;
inline long long int ham(pair<long long int, long long int> p1,
                         pair<long long int, long long int> p2) {
  return abs(p1.first - p2.first) + abs(p1.second - p2.second);
}
inline long long int traverse(pair<long long int, long long int> ps,
                              pair<long long int, long long int> pe,
                              pair<long long int, long long int> p1,
                              pair<long long int, long long int> p2) {
  return 2 * ham(ps, pe) - ham(p1, p2);
}
int main() {
  cin >> n;
  for (long long int i = 1; i <= n; ++i) {
    cin >> pts[i].first >> pts[i].second;
  }
  sort(pts + 1, pts + n + 1, cmp);
  for (long long int i = n; i >= 1; i--) {
    long long int j = i;
    tot++;
    long long int mx = max(pts[i].first, pts[i].second);
    for (long long int k = 1; k <= 5; ++k) best[tot][k] = pts[i];
    while (j >= 1 && max(pts[j].first, pts[j].second) == mx) j--;
    j++;
    for (long long int k = j + 1; k <= i - 1; ++k) {
      if (pts[j].first == pts[j].second) {
        best[tot][2] = pts[j - 1];
        best[tot][3] = pts[j];
        best[tot][4] = pts[j + 1];
        break;
      }
      if (pts[j].second == mx && pts[j + 1].second != mx) {
        best[tot][2] = pts[j];
        best[tot][3] = pts[j + 1];
        break;
      }
    }
    best[tot][5] = pts[j];
    for (long long int k = 1; k <= 5; ++k) {
      dp[tot][k] = inf;
      for (long long int k1 = 1; k1 <= 5; ++k1) {
        long long int dis =
            traverse(best[tot][1], best[tot][5], best[tot][k], best[tot][k1]);
        if (tot == 1) {
          dp[tot][k] = min(dp[tot][k], dis);
          continue;
        }
        for (long long int k2 = 1; k2 <= 5; ++k2) {
          long long int ndis = ham(best[tot][k1], best[tot - 1][k2]);
          dp[tot][k] = min(dp[tot][k], dis + ndis + dp[tot - 1][k2]);
        }
      }
    }
    i = j;
  }
  long long int ans = inf;
  for (long long int i = 1; i <= 5; ++i)
    ans = min(ans, dp[tot][i] + ham({0, 0}, best[tot][i]));
  cout << ans << '\n';
}
