#include <bits/stdc++.h>
using namespace std;
int n, m;
long long ans;
vector<int> a[200009];
struct A {
  int x, y;
} c[200009], cl[200009], cd[200009];
int dist[200009];
long long f[200009][2];
bool cmp(A i, A j) { return max(i.x, i.y) < max(j.x, j.y); }
bool cmp1(int x, int y) {
  return (c[x].x < c[y].x || (c[x].x == c[y].x && c[x].y > c[y].y));
}
bool cmp2(int x, int y) {
  return (c[x].y < c[y].y || (c[x].y == c[y].y && c[x].x > c[y].x));
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &c[i].x, &c[i].y);
  }
  sort(c + 1, c + n + 1, cmp);
  int m = 0;
  for (int i = 1; i <= n; i++) {
    if (max(c[i].x, c[i].y) != max(c[i - 1].x, c[i - 1].y)) {
      m++;
    }
    a[m].push_back(i);
  }
  for (int i = 1; i <= m; i++) {
    sort(a[i].begin(), a[i].end(), cmp1);
    for (int j = 1; j < a[i].size(); j++) {
      dist[i] += c[a[i][j]].x - c[a[i][j - 1]].x;
    }
    cl[i] = c[a[i][0]];
    sort(a[i].begin(), a[i].end(), cmp2);
    for (int j = 1; j < a[i].size(); j++) {
      dist[i] += c[a[i][j]].y - c[a[i][j - 1]].y;
    }
    cd[i] = c[a[i][0]];
  }
  long long disl, disd;
  for (int i = 1; i <= m; i++) {
    disl = abs(cl[i - 1].x - cl[i].x) + abs(cl[i - 1].y - cl[i].y);
    disd = abs(cd[i - 1].x - cl[i].x) + abs(cd[i - 1].y - cl[i].y);
    f[i][0] = min(f[i - 1][1] + disl, f[i - 1][0] + disd) + dist[i];
    disl = abs(cl[i - 1].x - cd[i].x) + abs(cl[i - 1].y - cd[i].y);
    disd = abs(cd[i - 1].x - cd[i].x) + abs(cd[i - 1].y - cd[i].y);
    f[i][1] = min(f[i - 1][0] + disd, f[i - 1][1] + disl) + dist[i];
  }
  cout << min(f[m][0], f[m][1]) << endl;
  return 0;
}
