#include <bits/stdc++.h>
using namespace std;
int in() {
  int x;
  scanf("%d", &x);
  return x;
}
long long lin() {
  long long x;
  scanf("%lld", &x);
  return x;
}
long long dist(pair<int, int> p1, pair<int, int> p2) {
  return abs(p1.first - p2.first) + abs(p1.second - p2.second);
}
int main() {
  int n;
  cin >> n;
  map<int, set<pair<int, int>>> p;
  for (int i = 0; i < n; ++i) {
    int x = in(), y = in();
    p[max(x, y)].insert(pair<int, int>(x, -y));
  }
  vector<pair<int, int>> p1, p2;
  p1.push_back(pair<int, int>(0, 0));
  p2.push_back(pair<int, int>(0, 0));
  for (auto hoge : p) {
    pair<int, int> tmp = *hoge.second.begin();
    tmp.second *= -1;
    p1.push_back(tmp);
    tmp = *hoge.second.rbegin();
    tmp.second *= -1;
    p2.push_back(tmp);
  }
  int m = p1.size();
  vector<vector<long long>> dp(m, vector<long long>(2, 1e18));
  dp[0][0] = dp[0][1] = 0;
  for (int i = 0; i < m - 1; ++i) {
    dp[i + 1][0] = min(dp[i][0] + dist(p1[i], p2[i + 1]),
                       dp[i][1] + dist(p2[i], p2[i + 1])) +
                   dist(p2[i + 1], p1[i + 1]);
    dp[i + 1][1] = min(dp[i][0] + dist(p1[i], p1[i + 1]),
                       dp[i][1] + dist(p2[i], p1[i + 1])) +
                   dist(p1[i + 1], p2[i + 1]);
  }
  cout << min(dp[m - 1][0], dp[m - 1][1]) << endl;
  return 0;
}
