#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  scanf("%d", &N);
  map<int, vector<pair<int, int>>> pts;
  vector<int> lvls;
  for (int i = 0; i < N; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    pts[max(x, y)].emplace_back(x, y);
    lvls.push_back(max(x, y));
  }
  pts[0].emplace_back(0, 0);
  lvls.push_back(0);
  sort(lvls.begin(), lvls.end());
  lvls.resize(unique(lvls.begin(), lvls.end()) - lvls.begin());
  for (auto& itr : pts) {
    vector<pair<int, int>>& P = itr.second;
    sort(P.begin(), P.end(), [&](pair<int, int> a, pair<int, int> b) {
      if (a.first == b.first) return a.second > b.second;
      return a.first < b.first;
    });
  }
  auto dist = [&](pair<int, int> a, pair<int, int> b) -> long long {
    return abs(b.first - a.first) + abs(b.second - a.second);
  };
  long long DP[2];
  int which = lvls.size() - 1;
  vector<pair<int, int>>& vec = pts[lvls[which]];
  DP[0] = DP[1] = 0;
  while (which > 0) {
    long long prev[2];
    memcpy(prev, DP, 2 * sizeof(long long));
    vector<pair<int, int>>& nvec = pts[lvls[--which]];
    long long full = dist(vec.front(), vec.back());
    DP[0] = DP[1] = 1e18;
    DP[0] = min(dist(nvec.back(), vec.back()) + full + prev[1], DP[0]);
    DP[0] = min(dist(nvec.back(), vec.front()) + full + prev[0], DP[0]);
    DP[1] = min(dist(nvec.front(), vec.back()) + full + prev[1], DP[1]);
    DP[1] = min(dist(nvec.front(), vec.front()) + full + prev[0], DP[1]);
    vec = nvec;
  }
  printf("%lld\n", min(DP[0], DP[1]));
  return 0;
}
