#include <bits/stdc++.h>
using namespace std;
long long pow_mod(long long x, long long y) {
  long long r = 1;
  for (; y; y >>= 1, x = (long long)x * x % 1000000007)
    if (y & 1) r = (long long)r * x % 1000000007;
  return r;
}
long long dis(pair<int, int> p1, pair<int, int> p2) {
  return labs((long long)p1.first - p2.first) +
         labs((long long)p1.second - p2.second);
}
int main() {
  int n;
  cin >> n;
  vector<pair<long long, pair<long long, long long> > > v;
  for (int i = 0; i < n; i++) {
    long long x, y;
    cin >> x >> y;
    v.push_back({max(x, y), {x, y}});
  }
  sort(v.begin(), v.end());
  vector<pair<long long, long long> > vm, vn;
  vn.push_back({0, 0});
  vm.push_back({0, 0});
  for (int i = 0; i < v.size();) {
    int f = i;
    long long lvl = v[i].first;
    pair<long long, long long> mx, mn;
    mx = {0, lvl};
    mn = {lvl, 0};
    while (i < n && v[f].first == v[i].first) {
      pair<long long, long long> pr = v[i].second;
      if (pr.first + abs(lvl - pr.second) < mn.first + abs(lvl - mn.second))
        mn = pr;
      if (pr.first + abs(lvl - pr.second) > mx.first + abs(lvl - mx.second))
        mx = pr;
      i++;
    }
    vn.push_back(mn);
    vm.push_back(mx);
  }
  int sz = vn.size();
  long long dp[sz][2];
  memset(dp, 0, sizeof(dp));
  for (int i = 1; i < sz; i++) {
    dp[i][1] = min(dp[i - 1][0] + dis(vn[i - 1], vn[i]),
                   dp[i - 1][1] + dis(vm[i - 1], vn[i]));
    dp[i][0] = min(dp[i - 1][1] + dis(vm[i - 1], vm[i]),
                   dp[i - 1][0] + dis(vn[i - 1], vm[i]));
    dp[i][1] += dis(vn[i], vm[i]);
    dp[i][0] += dis(vn[i], vm[i]);
  }
  cout << min(dp[sz - 1][0], dp[sz - 1][1]);
}
