#include <bits/stdc++.h>
using namespace std;
struct point {
  long long x, y;
  point(long long xx = 0, long long yy = 0) {
    x = xx;
    y = yy;
  }
  bool operator<(const point &b) const { return x == b.x ? y > b.y : x < b.x; }
};
const int maxn = 2e5 + 10;
long long n, x[maxn], y[maxn], r[maxn];
vector<point> v[maxn];
long long f[maxn][2], d[maxn];
const int cmp(const int i, const int j) {
  return max(x[i], y[i]) < max(x[j], y[j]);
}
long long dis(point a, point b) { return abs(a.x - b.x) + abs(a.y - b.y); }
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> x[i] >> y[i];
    r[i] = i;
  }
  sort(r + 1, r + 1 + n, cmp);
  int cnt = 0;
  x[0] = -1, y[0] = -1;
  for (int i = 1; i <= n; ++i) {
    if (max(x[r[i]], y[r[i]]) != max(x[r[i - 1]], y[r[i - 1]])) {
      v[++cnt].push_back({x[r[i]], y[r[i]]});
    } else
      v[cnt].push_back({x[r[i]], y[r[i]]});
  }
  for (int i = 1; i <= cnt; ++i) sort(v[i].begin(), v[i].end());
  v[0].push_back({0, 0});
  for (int i = 1; i <= cnt; ++i) {
    for (int j = 0; j < v[i].size() - 1; ++j) {
      d[i] += dis(v[i][j], v[i][j + 1]);
    }
  }
  memset(f, 63, sizeof f);
  f[0][0] = f[0][1] = 0;
  for (int i = 1; i <= cnt; ++i) {
    f[i][0] = d[i] + min(f[i - 1][0] + dis(v[i - 1][0], v[i][v[i].size() - 1]),
                         f[i - 1][1] + dis(v[i - 1][v[i - 1].size() - 1],
                                           v[i][v[i].size() - 1]));
    f[i][1] =
        d[i] + min(f[i - 1][0] + dis(v[i - 1][0], v[i][0]),
                   f[i - 1][1] + dis(v[i - 1][v[i - 1].size() - 1], v[i][0]));
  }
  cout << min(f[cnt][0], f[cnt][1]) << endl;
  return 0;
}
