#include <bits/stdc++.h>
using namespace std;
const long long siz = 2e5 + 2;
const long long SIZ = 1e6 + 2;
const long long mod = 1e9 + 7;
const long long maxx = 2e9;
const long long MAXX = 1e18;
const string file = "3";
long long m;
pair<long long, long long> p[siz];
long long dist_all[siz];
long long f[siz][2];
bool g[siz][2];
vector<pair<long long, long long> > lvl_set[siz];
long long dist(pair<long long, long long> a, pair<long long, long long> b) {
  return (abs(a.first - b.first) + abs(a.second - b.second));
}
long long dp(long long pos, long long cur_opt) {
  if (pos == m) {
    return dist_all[pos];
  }
  long long &res = f[pos][cur_opt];
  bool &cal = g[pos][cur_opt];
  if (cal) {
    return res;
  }
  res = MAXX;
  pair<long long, long long> sta =
      ((cur_opt) ? lvl_set[pos].front() : lvl_set[pos].back());
  for (long long nxt_opt = 0; nxt_opt <= 1; nxt_opt++) {
    pair<long long, long long> fin =
        ((nxt_opt) ? lvl_set[pos + 1].back() : lvl_set[pos + 1].front());
    res = min(res, dp(pos + 1, nxt_opt) + dist(sta, fin) + dist_all[pos]);
  }
  cal = true;
  return res;
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> p[i].first >> p[i].second;
  }
  map<long long, vector<pair<long long, long long> > > tmp;
  for (long long i = 1; i <= n; i++) {
    long long lvl = max(p[i].first, p[i].second);
    tmp[lvl].push_back(p[i]);
  }
  for (auto &x : tmp) {
    sort((x.second).begin(), (x.second).end(),
         [](pair<long long, long long> a, pair<long long, long long> b) {
           if (a.first == b.first) {
             return (a.second > b.second);
           }
           return (a.first < b.first);
         });
  }
  m = 0;
  for (auto x : tmp) {
    m++;
    for (long long i = 1; i < (long long)(x.second).size(); i++) {
      dist_all[m] += dist(x.second[i - 1], x.second[i]);
    }
    lvl_set[m] = x.second;
  }
  lvl_set[0] = {pair<long long, long long>(0, 0)};
  tmp.clear();
  cout << dp(0, 0) << "\n";
  return 0;
}
