#include <bits/stdc++.h>
long long mod = 1e9 + 7;
const int MAX = 1e5 + 5;
using namespace std;
bool cmp(pair<long long, long long> p1, pair<long long, long long> p2) {
  if (p1.first < p2.first)
    return true;
  else if (p1.first == p2.first && p1.second > p2.second)
    return true;
  else
    return false;
}
long long dp[200005][2];
long long dist(pair<long long, long long> p1, pair<long long, long long> p2) {
  return (abs(p1.first - p2.first) + abs(p1.second - p2.second));
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  vector<pair<long long, long long> > v(n);
  for (int i = 0; i < n; i++) cin >> v[i].first >> v[i].second;
  memset(dp, mod, sizeof(dp));
  map<long long, vector<pair<long long, long long> > > m;
  long long maxi = -1;
  for (int i = 0; i < n; i++) {
    long long level = max(v[i].first, v[i].second);
    m[level].push_back(v[i]);
    maxi = max(maxi, level);
  }
  m[0].push_back(make_pair(0, 0));
  for (map<long long, vector<pair<long long, long long> > >::iterator it =
           m.begin();
       it != m.end(); ++it) {
    sort((it->second).begin(), (it->second).end(), cmp);
  }
  dp[0][0] = 0;
  dp[0][1] = 0;
  int prev = 0;
  int lev = 0;
  for (map<long long, vector<pair<long long, long long> > >::iterator it =
           m.begin();
       it != m.end(); ++it) {
    lev++;
    int i = lev;
    pair<long long, long long> prev0 = m[prev][0];
    pair<long long, long long> prev1 = m[prev].back();
    pair<long long, long long> curr0 = it->second[0];
    pair<long long, long long> curr1 = it->second.back();
    dp[i][0] =
        min(dp[i][0], dp[i - 1][0] + (dist(prev0, curr1) + dist(curr1, curr0)));
    dp[i][0] =
        min(dp[i][0], dp[i - 1][1] + (dist(prev1, curr1) + dist(curr1, curr0)));
    dp[i][1] =
        min(dp[i][1], dp[i - 1][0] + (dist(prev0, curr0) + dist(curr0, curr1)));
    dp[i][1] =
        min(dp[i][1], dp[i - 1][1] + (dist(prev1, curr0) + dist(curr0, curr1)));
    prev = it->first;
  }
  cout << min(dp[lev][0], dp[lev][1]);
  return 0;
}
