#include <bits/stdc++.h>
using namespace std;
const long long INF64 = 1e18;
long long dist(pair<int, int> a, pair<int, int> b) {
  return abs(a.first - b.first) + abs(a.second - b.second);
}
int main() {
  int n;
  map<int, vector<pair<int, int>>> pts;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int x, y;
    cin >> x >> y;
    pts[max(x, y)].push_back(make_pair(x, y));
  }
  pts[0].push_back(make_pair(0, 0));
  for (auto &it : pts) {
    sort(it.second.begin(), it.second.end(),
         [&](pair<int, int> a, pair<int, int> &b) {
           if (a.first == b.first) return a.second > b.second;
           return a.first < b.first;
         });
  }
  vector<vector<long long>> dp(int(pts.size()) + 1,
                               vector<long long>(2, INF64));
  dp[0][0] = dp[0][1] = 0;
  int lvl = 0;
  int prv = 0;
  for (auto &it : pts) {
    ++lvl;
    pair<int, int> curl = it.second[0];
    pair<int, int> curr = it.second.back();
    pair<int, int> prvl = pts[prv][0];
    pair<int, int> prvr = pts[prv].back();
    dp[lvl][0] =
        min(dp[lvl][0], dp[lvl - 1][0] + dist(prvl, curr) + dist(curl, curr));
    dp[lvl][0] =
        min(dp[lvl][0], dp[lvl - 1][1] + dist(prvr, curr) + dist(curl, curr));
    dp[lvl][1] =
        min(dp[lvl][1], dp[lvl - 1][0] + dist(prvl, curl) + dist(curl, curr));
    dp[lvl][1] =
        min(dp[lvl][1], dp[lvl - 1][1] + dist(prvr, curl) + dist(curl, curr));
    prv = it.first;
  }
  cout << min(dp[lvl][0], dp[lvl][1]) << endl;
  return 0;
}
