#include <bits/stdc++.h>
using namespace std;
set<long long> s;
set<long long>::iterator it;
long long n, timer, dp[200005][5], m;
map<long long, long long> mp;
vector<pair<long long, long long> > bg, en, v[200005];
vector<long long> sz, val;
void take_input() {
  mp.clear();
  timer = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    long long x, y, idx;
    cin >> x >> y;
    idx = max(x, y);
    s.insert(idx);
    if (!mp[idx]) {
      val.push_back(idx);
      timer++;
      mp[idx] = timer;
    }
    v[mp[idx]].push_back(make_pair(x, ((-1LL) * (y))));
  }
  return;
}
void prcs() {
  sort(val.begin(), val.end());
  for (int i = 0; i < val.size(); i++) {
    long long idx, pos, xx1, yy1, xx2, yy2, len;
    idx = val[i];
    pos = mp[idx];
    len = v[pos].size();
    sort(v[pos].begin(), v[pos].end());
    xx1 = v[pos][0].first;
    xx2 = v[pos][len - 1].first;
    yy1 = (-1LL) * v[pos][0].second;
    yy2 = (-1LL) * v[pos][len - 1].second;
    bg.push_back(make_pair(xx1, yy1));
    en.push_back(make_pair(xx2, yy2));
    sz.push_back(abs(xx1 - xx2) + abs(yy1 - yy2));
  }
  m = val.size();
  return;
}
long long dis(long long x1, long long y1, long long x2, long long y2) {
  long long res = abs(x1 - x2) + abs(y1 - y2);
  return res;
}
long long rec(long long idx, long long f) {
  if (dp[idx][f] != -1) return dp[idx][f];
  if (idx == m) {
    return sz[idx - 1];
  }
  long long res = 1e18;
  if (!idx) {
    res = min(res,
              dis(0LL, 0LL, bg[idx].first, bg[idx].second) + rec(idx + 1, 0LL));
    res = min(res,
              dis(0LL, 0LL, en[idx].first, en[idx].second) + rec(idx + 1, 1LL));
  } else {
    if (f) {
      res = min(res, dis(bg[idx - 1].first, bg[idx - 1].second, bg[idx].first,
                         bg[idx].second) +
                         sz[idx - 1] + rec(idx + 1, 0LL));
      res = min(res, dis(bg[idx - 1].first, bg[idx - 1].second, en[idx].first,
                         en[idx].second) +
                         sz[idx - 1] + rec(idx + 1, 1LL));
    } else {
      res = min(res, dis(en[idx - 1].first, en[idx - 1].second, bg[idx].first,
                         bg[idx].second) +
                         sz[idx - 1] + rec(idx + 1, 0LL));
      res = min(res, dis(en[idx - 1].first, en[idx - 1].second, en[idx].first,
                         en[idx].second) +
                         sz[idx - 1] + rec(idx + 1, 1LL));
    }
  }
  return dp[idx][f] = res;
}
int main(int argc, char const *argv[]) {
  take_input();
  prcs();
  memset(dp, -1, sizeof dp);
  long long ans = rec(0, 0);
  cout << ans << endl;
  return 0;
}
