#include <bits/stdc++.h>
using namespace std;
struct coordinate {
  int x, y;
  int level;
  coordinate(){};
  coordinate(int X, int Y) : x(X), y(Y){};
};
inline int abs(int x) {
  if (x < 0) return -x;
  return x;
}
inline bool cmp(coordinate a, coordinate b) { return a.level < b.level; }
inline long long getdis(coordinate a, coordinate b) {
  return abs(a.x - b.x) + abs(a.y - b.y);
}
long long dp[200240][2];
coordinate store[200240];
int main() {
  int len;
  store[0].x = 0, store[0].y = 0, store[0].level = 0;
  scanf("%d", &len);
  for (int i = 1; i <= len; i++) dp[i][0] = 0x3f3f3f3f, dp[i][1] = 0x3f3f3f3f;
  for (int i = 1; i <= len; i++) {
    scanf("%d %d", &store[i].x, &store[i].y);
    store[i].level = max(store[i].x, store[i].y);
  }
  sort(store + 1, store + len + 1, cmp);
  int nowLevel = store[1].level;
  coordinate *lastLeft = &store[0], *lastDown = &store[0];
  coordinate inf(INT_MAX, INT_MAX);
  coordinate *nextLeft = &inf, *nextDown = &inf;
  int i = 1, j = 1;
  while (i <= len) {
    if (store[i].level == nowLevel) {
      if (store[i].x < nextLeft->x)
        nextLeft = &store[i];
      else if (store[i].x == nextLeft->x && store[i].y > nextLeft->y)
        nextLeft = &store[i];
      if (store[i].y < nextDown->y)
        nextDown = &store[i];
      else if (store[i].y == nextDown->y && store[i].x > nextDown->x)
        nextDown = &store[i];
      i++;
    } else {
      nowLevel = store[i].level;
      long long dis0 = getdis(*nextDown, *nextLeft);
      long long dis1 = getdis(*lastDown, *nextDown);
      long long dis2 = getdis(*lastDown, *nextLeft);
      long long dis3 = getdis(*lastLeft, *nextDown);
      long long dis4 = getdis(*lastLeft, *nextLeft);
      dp[j][0] = min(dp[j - 1][0] + dis0 + dis2, dp[j - 1][1] + dis0 + dis4);
      dp[j][1] = min(dp[j - 1][0] + dis0 + dis1, dp[j - 1][1] + dis0 + dis3);
      j++;
      lastLeft = nextLeft, lastDown = nextDown;
      nextDown = &inf, nextLeft = &inf;
    }
  }
  long dis0 = getdis(*nextDown, *nextLeft);
  long dis1 = getdis(*lastDown, *nextDown);
  long dis2 = getdis(*lastDown, *nextLeft);
  long dis3 = getdis(*lastLeft, *nextDown);
  long dis4 = getdis(*lastLeft, *nextLeft);
  dp[j][0] = min(dp[j - 1][0] + dis0 + dis2, dp[j - 1][1] + dis0 + dis4);
  dp[j][1] = min(dp[j - 1][0] + dis0 + dis1, dp[j - 1][1] + dis0 + dis3);
  printf("%lld\n", min(dp[j][0], dp[j][1]));
  return 0;
}
