#include <bits/stdc++.h>
using namespace std::chrono;
using namespace std;
void printvpl(vector<pair<long long int, long long int> > &v) {
  long long int n = v.size();
  for (long long int i = 0; i < n; i++)
    cout << "(" << v[i].first << "," << v[i].second << ")";
  cout << "\n";
  ;
}
bool comp(const pair<long long int, long long int> &a,
          const pair<long long int, long long int> &b) {
  long long int p = max(a.first, a.second);
  long long int q = max(b.first, b.second);
  if (p != q) return p < q;
  if (a.first != b.first) return a.first < b.first;
  return a.second > b.second;
}
long long int calc(pair<long long int, long long int> &a,
                   pair<long long int, long long int> &b) {
  long long int ans = 0;
  ans = abs(a.first - b.first);
  ans += abs(a.second - b.second);
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  long long int n;
  cin >> n;
  vector<pair<long long int, long long int> > v(n);
  for (long long int i = 0; i < n; i++) {
    long long int a, b;
    cin >> a >> b;
    v[i] = make_pair(a, b);
  }
  sort(v.begin(), v.end(), comp);
  vector<vector<pair<long long int, long long int> > > points;
  long long int i = 0;
  while (i < n) {
    long long int j = i;
    pair<long long int, long long int> p = v[i];
    long long int m1 = max(p.first, p.second);
    vector<pair<long long int, long long int> > temp;
    while (j < n and max(v[j].first, v[j].second) == m1) {
      temp.push_back(v[j]);
      j++;
    }
    points.push_back(temp);
    i = j;
  }
  long long int n1 = points.size();
  vector<vector<long long int> > dp(n1, vector<long long int>(2, INT_MAX));
  for (long long int i = n1 - 1; i >= 0; i--) {
    long long int n2 = points[i].size();
    long long int dist = calc(points[i][0], points[i].back());
    if (i == n1 - 1) {
      dp[i][0] = dist;
      dp[i][1] = dist;
    } else {
      long long int p1 =
          min(dp[i + 1][1] + calc(points[i].back(), points[i + 1].back()),
              dp[i + 1][0] + calc(points[i].back(), points[i + 1][0]));
      long long int p2 =
          min(dp[i + 1][0] + calc(points[i][0], points[i + 1][0]),
              dp[i + 1][1] + calc(points[i][0], points[i + 1].back()));
      dp[i][0] = dist + p1;
      dp[i][1] = dist + p2;
    }
  }
  pair<long long int, long long int> init = {0, 0};
  long long int ans = min(dp[0][0] + calc(init, points[0][0]),
                          dp[0][1] + calc(init, points[0].back()));
  cout << ans << "\n";
  ;
  return 0;
}
