#include <bits/stdc++.h>
using namespace std;
inline void read(long long &x) {
  x = 0;
  long long f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = (x << 1) + (x << 3) + (c ^ 48);
    c = getchar();
  }
  x *= f;
}
const long long N = 2e5;
long long x[N + 10], y[N + 10], t[N * 2 + 10];
struct node {
  long long x, y;
  node(long long xx, long long yy) {
    x = xx;
    y = yy;
  }
  node() {}
  bool operator<(const node &rhs) const {
    return y == rhs.y ? x < rhs.x : y > rhs.y;
  }
};
vector<node> p[N + 10];
long long c[N + 10], f[N + 10][2];
long long dis(node a, node b) { return abs(a.x - b.x) + abs(a.y - b.y); }
signed main() {
  long long n, m = 0;
  scanf("%lld", &n);
  for (long long i = 1; i <= n; i++) {
    scanf("%lld %lld", &x[i], &y[i]);
    t[++m] = max(x[i], y[i]);
  }
  sort(t + 1, t + m + 1);
  m = unique(t + 1, t + m + 1) - t - 1;
  for (long long i = 1; i <= n; i++)
    p[lower_bound(t + 1, t + m + 1, max(x[i], y[i])) - t].push_back(
        node(x[i], y[i]));
  p[0].push_back(node(0, 0));
  for (long long i = 1; i <= n; i++) sort(p[i].begin(), p[i].end());
  for (long long i = 1; i <= m; i++) {
    for (long long j = 1; (unsigned)j < p[i].size(); j++)
      c[i] += dis(p[i][j], p[i][j - 1]);
  }
  for (long long i = 1; i <= m; i++) {
    vector<node>::iterator it0 = p[i - 1].begin(), it1 = --p[i - 1].end();
    vector<node>::iterator now0 = p[i].begin(), now1 = --p[i].end();
    f[i][0] = min(f[i - 1][0] + dis(*it0, *now1) + c[i],
                  f[i - 1][1] + dis(*it1, *now1) + c[i]);
    f[i][1] = min(f[i - 1][0] + dis(*it0, *now0) + c[i],
                  f[i - 1][1] + dis(*it1, *now0) + c[i]);
  }
  printf("%lld\n", min(f[m][0], f[m][1]));
}
