#include <bits/stdc++.h>
using namespace std;
const int N = (int)2e5 + 10;
struct A {
  int x, y, m;
  A(int x = 0, int y = 0) : x(x), y(y) {}
} da[N];
int cnt;
long long dp[N][2];
A cor[N][2];
map<int, int> M, rM;
int cmp(A a, A b) {
  if (a.m == b.m) {
    if (a.x == b.x)
      return a.y < b.y;
    else
      return a.x > b.x;
  } else
    return a.m < b.m;
}
long long cal(A a, A b) { return abs(a.x - b.x) + abs(a.y - b.y); }
int main() {
  int n;
  while (~scanf("%d", &n)) {
    da[0].x = 0, da[0].y = 0;
    for (int i = 1; i <= n; ++i) {
      scanf("%d%d", &da[i].y, &da[i].x);
      da[i].m = max(da[i].y, da[i].x);
    }
    sort(da, da + n + 1, cmp);
    int tem = -1, cnt = -1;
    for (int i = 0; i <= n; ++i) {
      if (tem != da[i].m) {
        ++cnt;
        cor[cnt][0] = da[i];
        cor[cnt][1] = da[i];
        tem = da[i].m;
      } else {
        cor[cnt][1] = da[i];
      }
    }
    dp[0][0] = cor[0][1].y;
    dp[0][1] = cor[0][1].y;
    for (int i = 1; i <= cnt; ++i) {
      A a = cor[i - 1][0], b = cor[i - 1][1], c = cor[i][0], d = cor[i][1];
      long long l1 = dp[i - 1][0] + cal(a, d) + cal(d, c);
      long long l2 = dp[i - 1][1] + cal(b, d) + cal(d, c);
      dp[i][0] = min(l1, l2);
      long long r1 = dp[i - 1][0] + cal(a, c) + cal(c, d);
      long long r2 = dp[i - 1][1] + cal(b, c) + cal(c, d);
      dp[i][1] = min(r1, r2);
    }
    printf("%lld\n", min(dp[cnt][0], dp[cnt][1]));
  }
  return 0;
}
