#include <bits/stdc++.h>
using namespace std;
long long n, tot;
struct point {
  long long x, y;
} p[200005], l[200005][2];
long long dis(point A, point B) {
  long long X = A.x - B.x;
  X = X < 0 ? -X : X;
  long long Y = A.y - B.y;
  Y = Y < 0 ? -Y : Y;
  return X + Y;
}
bool cmp1(point A, point B) { return max(A.x, A.y) < max(B.x, B.y); }
bool cmp2(point A, point B) {
  if (A.x == B.x) return A.y > B.y;
  return A.x < B.x;
}
long long f[200005][2];
int main() {
  scanf("%lld", &n);
  for (int i = 1; i <= n; i++) scanf("%lld%lld", &p[i].x, &p[i].y);
  sort(p + 1, p + 1 + n, cmp1);
  int last = 1;
  for (int i = 1; i <= n; ++i) {
    if (max(p[i].x, p[i].y) != max(p[i + 1].x, p[i + 1].y)) {
      sort(p + last, p + i + 1, cmp2);
      l[++tot][0] = p[last];
      l[tot][1] = p[i];
      last = i + 1;
    }
  }
  memset(f, 0x3f, sizeof(f));
  f[0][0] = f[0][1] = 0;
  for (int i = 1; i <= tot; ++i) {
    f[i][0] = min(f[i][0], f[i - 1][0] + dis(l[i][1], l[i - 1][0]) +
                               dis(l[i][1], l[i][0]));
    f[i][0] = min(f[i][0], f[i - 1][1] + dis(l[i][1], l[i - 1][1]) +
                               dis(l[i][1], l[i][0]));
    f[i][1] = min(f[i][1], f[i - 1][0] + dis(l[i][0], l[i - 1][0]) +
                               dis(l[i][1], l[i][0]));
    f[i][1] = min(f[i][1], f[i - 1][1] + dis(l[i][0], l[i - 1][1]) +
                               dis(l[i][1], l[i][0]));
  }
  printf("%lld", min(f[tot][0], f[tot][1]));
  return 0;
}
