#include <bits/stdc++.h>
using namespace std;
ifstream in;
ofstream out;
const long long kk = 1000;
const long long ml = kk * kk;
const long long mod = ml * kk + 7;
const long long inf = ml * ml * ml + 7;
long long n, i, j;
vector<long long> m;
bool viv = false;
set<long long> s;
map<long long, vector<pair<long long, long long> > > mp;
long long rast(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 (i = 0; i < n; i++) {
    long long a, b;
    cin >> a >> b;
    s.insert(max(a, b));
    mp[max(a, b)].push_back({a, -b});
  }
  for (auto v : s) sort(mp[v].begin(), mp[v].end());
  long long a = 0;
  long long b = 0;
  pair<long long, long long> sp = {0, 0};
  pair<long long, long long> se = {0, 0};
  for (auto v : s) {
    pair<long long, long long> nsp = mp[v][0];
    pair<long long, long long> nse = mp[v].back();
    long long na = min(a + rast(se, nsp), b + rast(sp, nsp));
    long long nb = min(a + rast(se, nse), b + rast(sp, nse));
    long long r = rast(nsp, nse);
    na += r, nb += r;
    se = nse;
    sp = nsp;
    a = na;
    b = nb;
  }
  cout << min(a, b);
  return 0;
}
