#include <bits/stdc++.h>
using namespace std;
map<long long, vector<pair<long long, long long> > > mp;
long long dis(pair<long long, long long> a, pair<long long, long long> b) {
  return abs(a.first - b.first) + abs(a.second - b.second);
}
int main() {
  long long n;
  scanf("%lld", &n);
  for (long long i = 0; i < n; i++) {
    long long x, y;
    scanf("%lld%lld", &x, &y);
    mp[max(x, y)].push_back(pair<long long, long long>(x, y));
  }
  pair<long long, long long> left(0, 0), right(0, 0);
  long long dl = 0, dr = 0;
  for (auto &pr : mp) {
    sort(pr.second.begin(), pr.second.end(),
         [](pair<long long, long long> a, pair<long long, long long> b) {
           return make_pair(a.first, -a.second) < make_pair(b.first, -b.second);
         });
    pair<long long, long long> nl = *pr.second.begin();
    pair<long long, long long> nr = pr.second.back();
    long long dd = dis(nl, nr);
    long long ndl = min(dl + dis(left, nr) + dd, dr + dis(right, nr) + dd);
    long long ndr = min(dl + dis(left, nl) + dd, dr + dis(right, nl) + dd);
    dl = ndl;
    dr = ndr;
    left = nl;
    right = nr;
  }
  printf("%lld\n", min(dl, dr));
  return 0;
}
