#include <bits/stdc++.h>
using namespace std;
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << endl;
  err(++it, args...);
}
long long int get_dist(pair<int, int> p1, pair<int, int> p2) {
  return abs(p1.first - p2.first) + abs(p2.second - p1.second);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, x, y;
  cin >> n;
  vector<tuple<long long int, long long int, long long int>> v, vv;
  int i = 0;
  while (i < n) {
    cin >> x >> y;
    v.push_back(make_tuple(max(x, y), x, y));
    i++;
  }
  sort(v.begin(), v.end());
  map<int, pair<int, int>> anticlockwise_start, clockwise_start;
  for (int i = 0; i < n;) {
    int j = i;
    anticlockwise_start[get<0>(v[i])] = {-1, INT_MAX};
    clockwise_start[get<0>(v[i])] = {INT_MAX, -1};
    while (j < n && get<0>(v[i]) == get<0>(v[j])) {
      if (get<1>(v[j]) >= anticlockwise_start[get<0>(v[i])].first &&
          get<2>(v[j]) <= anticlockwise_start[get<0>(v[i])].second)
        anticlockwise_start[get<0>(v[i])] = {get<1>(v[j]), get<2>(v[j])};
      if (get<1>(v[j]) <= clockwise_start[get<0>(v[i])].first &&
          get<2>(v[j]) >= clockwise_start[get<0>(v[i])].second)
        clockwise_start[get<0>(v[i])] = {get<1>(v[j]), get<2>(v[j])};
      j++;
    }
    i = j;
  }
  map<pair<int, int>, long long int> dp;
  long long int dist1, dist2;
  dp[anticlockwise_start[get<0>(v[n - 1])]] = get_dist(
      anticlockwise_start[get<0>(v[n - 1])], clockwise_start[get<0>(v[n - 1])]);
  dp[clockwise_start[get<0>(v[n - 1])]] =
      dp[anticlockwise_start[get<0>(v[n - 1])]];
  int prev;
  for (int i = n - 1; i >= 0;) {
    if (get<0>(v[i]) == get<0>(v[n - 1])) {
      prev = get<0>(v[n - 1]);
      i--;
      continue;
    }
    int j = i;
    while (j >= 0 && get<0>(v[i]) == get<0>(v[j])) j--;
    dist1 =
        get_dist(anticlockwise_start[get<0>(v[i])], anticlockwise_start[prev]);
    dist2 = get_dist(anticlockwise_start[get<0>(v[i])], clockwise_start[prev]);
    dp[anticlockwise_start[get<0>(v[i])]] =
        min(dp[anticlockwise_start[prev]] + dist1,
            dp[clockwise_start[prev]] + dist2);
    dist1 = get_dist(clockwise_start[get<0>(v[i])], anticlockwise_start[prev]);
    dist2 = get_dist(clockwise_start[get<0>(v[i])], clockwise_start[prev]);
    dp[clockwise_start[get<0>(v[i])]] =
        min(dp[anticlockwise_start[prev]] + dist1,
            dp[clockwise_start[prev]] + dist2);
    dist1 = get_dist(clockwise_start[get<0>(v[i])],
                     anticlockwise_start[get<0>(v[i])]);
    long long int temp = dp[anticlockwise_start[get<0>(v[i])]];
    dp[anticlockwise_start[get<0>(v[i])]] =
        dist1 + dp[clockwise_start[get<0>(v[i])]];
    dp[clockwise_start[get<0>(v[i])]] = dist1 + temp;
    prev = get<0>(v[i]);
    i = j;
  }
  dist1 = get_dist({0, 0}, anticlockwise_start[prev]);
  dist2 = get_dist({0, 0}, clockwise_start[prev]);
  cout << min(dp[anticlockwise_start[prev]] + dist1,
              dp[clockwise_start[prev]] + dist2);
  return 0;
}
