#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 1e6 + 10;
long long n, x, y;
map<long long, vector<pair<long long, long long> > > v;
set<long long> dif;
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);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x >> y;
    dif.insert(max(x, y));
    v[max(x, y)].push_back({x, y});
  }
  pair<pair<long long, long long>, long long> l, r;
  l = {{0, 0}, 0};
  r = l;
  for (auto i = dif.begin(); i != dif.end(); i++) {
    long long maxx = *i;
    pair<long long, long long> nl = {1000000010, 1000000010},
                               nr = {1000000010, 1000000010};
    for (int j = 0; j < v[maxx].size(); j++) {
      if (v[maxx][j].first < nl.first ||
          (v[maxx][j].first == nl.first && v[maxx][j].second > nl.second))
        nl = v[maxx][j];
      if (v[maxx][j].second < nr.second || (v[maxx][j].first > nr.first))
        nr = v[maxx][j];
    }
    pair<pair<long long, long long>, long long> g, h;
    g.first = nl;
    h.first = nr;
    g.second = min(l.second + dist(l.first, nr) + dist(nr, nl),
                   r.second + dist(r.first, nr) + dist(nr, nl));
    h.second = min(l.second + dist(l.first, nl) + dist(nl, nr),
                   r.second + dist(r.first, nl) + dist(nl, nr));
    l = g;
    r = h;
  }
  cout << min(l.second, r.second);
  return 0;
}
