#include <bits/stdc++.h>
using namespace std;
const double eps = 1.0e-5;
const int maxn = 200000 + 10;
int n, len = 1, t = 1;
long long dp[maxn][2], ans = 0;
struct node {
  int x, y;
} a[maxn], tmp;
vector<node> vec[maxn];
bool cmp(node a, node b) {
  if (max(a.x, a.y) == max(b.x, b.y)) return a.x == b.x ? a.y < b.y : a.x > b.x;
  return max(a.x, a.y) < max(b.x, b.y);
}
long long solve(long long tmp) { return tmp >= 0 ? tmp : -tmp; }
long long get_remain() {
  dp[1][0] = dp[1][1] = 0;
  for (int i = 1; i <= len; i++) {
    long long dis00 = solve(vec[i - 1][0].x - vec[i][0].x) +
                      solve(vec[i - 1][0].y - vec[i][0].y);
    long long dis01 = solve(vec[i - 1][0].x - vec[i][1].x) +
                      solve(vec[i - 1][0].y - vec[i][1].y);
    long long dis10 = solve(vec[i - 1][1].x - vec[i][0].x) +
                      solve(vec[i - 1][1].y - vec[i][0].y);
    long long dis11 = solve(vec[i - 1][1].x - vec[i][1].x) +
                      solve(vec[i - 1][1].y - vec[i][1].y);
    dp[i][0] = min(dp[i - 1][0] + dis10, dp[i - 1][1] + dis00);
    dp[i][1] = min(dp[i - 1][1] + dis01, dp[i - 1][0] + dis11);
  }
  return min(dp[len][0], dp[len][1]);
}
void init() {
  tmp.x = tmp.y = 0;
  vec[0].push_back(tmp);
  vec[0].push_back(tmp);
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d%d", &a[i].x, &a[i].y);
  sort(a + 1, a + n + 1, cmp);
}
int main() {
  init();
  while (t <= n) {
    vec[len].push_back(a[t]);
    int fir = t;
    while (t < n && max(a[t + 1].x, a[t + 1].y) == max(a[fir].x, a[fir].y)) t++;
    vec[len++].push_back(a[t]);
    ans += (solve((long long)(a[t].x - a[fir].x)) +
            solve((long long)(a[t].y - a[fir].y)));
    t++;
  }
  len--;
  ans += get_remain();
  printf("%lld\n", ans);
}
