#include <bits/stdc++.h>
#pragma GCC optimize(2)
const long long INF = 0x3f3f3f3f3f3f3f3f;
const int maxn = 2e5 + 10;
using namespace std;
template <typename _Tp>
inline _Tp Max(_Tp a, _Tp b) {
  return a > b ? a : b;
}
template <typename _Tp>
inline _Tp Min(_Tp a, _Tp b) {
  return a < b ? a : b;
}
long long dp[maxn][2];
long long tmp[maxn];
struct point {
  long long x, y;
  long long r;
  point() {}
  point(int x, int y) : x(x), y(y), r(Max(x, y)) {}
  bool operator<(const point &rhs) const { return r < rhs.r; }
} a[maxn];
bool cmp(point &a, point &b) {
  if (a.r == b.r) {
    if (a.x == b.x)
      return a.y > b.y;
    else
      return a.x < b.x;
  } else
    return a.r < b.r;
}
int n;
long long ans = INF;
struct inter {
  int l, r;
  long long w;
} pos[maxn];
template <typename _Tp>
void gi(_Tp &x) {
  x = 0;
  char ch = getchar(), lst = ' ';
  while (!isdigit(ch)) {
    lst = ch;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = (x << 1) + (x << 3) + (ch & 15);
    ch = getchar();
  }
  if (lst == '-') x = -x;
}
int main() {
  gi(n);
  int x, y;
  for (int i = 1; i <= n; ++i) {
    gi(x);
    gi(y);
    a[i] = point(x, y);
  }
  sort(a + 1, a + n + 1, cmp);
  int p = 0;
  int size = 1;
  while (p < n) {
    pos[size].l = pos[size - 1].r + 1;
    p = upper_bound(a + 1, a + n + 1, a[pos[size].l]) - a;
    pos[size].r = --p;
    pos[size].w = (abs(a[pos[size].r].x - a[pos[size].l].x) +
                   abs(a[pos[size].r].y - a[pos[size].l].y));
    size++;
  }
  size--;
  memset(dp, 0x3f, sizeof(dp));
  dp[0][0] = dp[0][1] = 0;
  for (int k = 1; k <= size; ++k) {
    dp[k][1] = min(dp[k - 1][0] + (abs(a[pos[k - 1].l].x - a[pos[k].l].x) +
                                   abs(a[pos[k - 1].l].y - a[pos[k].l].y)),
                   dp[k - 1][1] + (abs(a[pos[k - 1].r].x - a[pos[k].l].x) +
                                   abs(a[pos[k - 1].r].y - a[pos[k].l].y))) +
               pos[k].w;
    dp[k][0] = min(dp[k - 1][1] + (abs(a[pos[k - 1].r].x - a[pos[k].r].x) +
                                   abs(a[pos[k - 1].r].y - a[pos[k].r].y)),
                   dp[k - 1][0] + (abs(a[pos[k - 1].l].x - a[pos[k].r].x) +
                                   abs(a[pos[k - 1].l].y - a[pos[k].r].y))) +
               pos[k].w;
  }
  ans = min(dp[size][0], dp[size][1]);
  printf("%I64d", ans);
  return 0;
}
