#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 100;
const long long INF = 1e18;
int N;
pair<int, int> pts[MAXN];
long long dp[MAXN][2];
pair<int, int> mn[MAXN][2];
int cmp1(const pair<int, int>& a, const pair<int, int>& b) {
  return max(b.first, b.second) - max(a.first, a.second);
}
bool cmp2(const pair<int, int>& a, const pair<int, int>& b) {
  assert(max(a.first, a.second) == max(b.first, b.second));
  return a.first == b.first ? a.second > b.second : a.first < b.first;
}
long long dist(const pair<int, int>& a, const pair<int, int>& b) {
  return static_cast<long long>(abs(b.first - a.first)) +
         static_cast<long long>(abs(b.second - a.second));
}
int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; i++) scanf("%d%d", &pts[i].first, &pts[i].second);
  sort(pts, pts + N, [](const pair<int, int>& a, const pair<int, int>& b) {
    return max(a.first, a.second) < max(b.first, b.second);
  });
  int lvl = 0;
  for (int i = 0, j; i < N; i = j, lvl++) {
    for (int k = 0; k < 2; k++) mn[lvl][k] = pts[i];
    for (j = i + 1; j < N and cmp1(pts[i], pts[j]) == 0; j++) {
      if (cmp2(pts[j], mn[lvl][0])) mn[lvl][0] = pts[j];
      if (cmp2(mn[lvl][1], pts[j])) mn[lvl][1] = pts[j];
    }
  }
  long long fd = dist(mn[0][0], mn[0][1]);
  dp[0][0] = dist(make_pair(0, 0), mn[0][1]) + fd;
  dp[0][1] = dist(make_pair(0, 0), mn[0][0]) + fd;
  long long t;
  for (int i = 1; i < lvl; i++) {
    for (int j = 0; j < 2; j++) dp[i][j] = INF;
    fd = dist(mn[i][0], mn[i][1]);
    for (int j = 0; j < 2; j++)
      for (int k = 0; k < 2; k++)
        if ((t = dp[i - 1][k] + dist(mn[i][j ^ 1], mn[i - 1][k]) + fd) <
            dp[i][j])
          dp[i][j] = t;
  }
  printf("%lld\n", min(dp[lvl - 1][0], dp[lvl - 1][1]));
  return 0;
}
