#include <bits/stdc++.h>
const int MAXN = 200000 + 10;
int n, cnt, st[MAXN], ed[MAXN];
long long ans1, ans2;
struct node {
  int x, y, val;
  inline bool operator<(const node &A) const {
    if (val != A.val)
      return val < A.val;
    else if (x != A.x)
      return x < A.x;
    else
      return y > A.y;
  };
};
node pt[MAXN];
template <typename T>
inline void read(T &x) {
  T data = 0, w = 1;
  char ch = 0;
  while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
  if (ch == '-') w = -1, ch = getchar();
  while (ch >= '0' && ch <= '9')
    data = ((T)data << 3) + ((T)data << 1) + (ch ^ '0'), ch = getchar();
  x = data * w;
}
template <typename T>
inline void write(T x, char ch = '\0') {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
  if (ch != '\0') putchar(ch);
}
template <typename T>
inline void chkmin(T &x, T y) {
  x = (y < x ? y : x);
}
template <typename T>
inline void chkmax(T &x, T y) {
  x = (y > x ? y : x);
}
template <typename T>
inline T min(T x, T y) {
  return x < y ? x : y;
}
template <typename T>
inline T max(T x, T y) {
  return x > y ? x : y;
}
inline long long dist(node A, node B) {
  return abs(A.x - B.x) + abs(A.y - B.y);
}
int main() {
  read(n);
  pt[0] = (node){0, 0, 0};
  for (register int i = (1), iend = (n); i <= iend; ++i) {
    read(pt[i].x), read(pt[i].y);
    pt[i].val = max(pt[i].x, pt[i].y);
  }
  std::sort(pt + 1, pt + n + 1);
  for (register int i = (1), iend = (n); i <= iend; ++i) {
    ++cnt;
    st[cnt] = i, ed[cnt] = i;
    while (pt[ed[cnt] + 1].val == pt[st[cnt]].val) {
      ed[cnt]++;
      ans1 += dist(pt[ed[cnt]], pt[ed[cnt] - 1]);
      ans2 += dist(pt[ed[cnt]], pt[ed[cnt] - 1]);
    }
    long long res1 = min(ans1 + dist(pt[st[cnt - 1]], pt[ed[cnt]]),
                         ans2 + dist(pt[ed[cnt - 1]], pt[ed[cnt]]));
    long long res2 = min(ans1 + dist(pt[st[cnt - 1]], pt[st[cnt]]),
                         ans2 + dist(pt[ed[cnt - 1]], pt[st[cnt]]));
    ans1 = res1, ans2 = res2;
    i = ed[cnt];
  }
  write(min(ans1, ans2), '\n');
  return 0;
}
