#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 2e9 + 5;
struct level {
  int l;
  vector<pii> p;
};
ll dist(pii &a, pii &b) {
  return abs(a.first - b.first) + abs(a.second - b.second);
}
int get_level(pii &p) { return max(p.first, p.second); }
ll solve(int i, vector<level> &l, bool side, vector<vector<ll>> &memo) {
  ll &state = memo[i][side];
  if (state != -1) return state;
  if (i == l.size() - 1) return state = 0;
  pii current = l[i].p[side];
  ll reach_left = dist(current, l[i + 1].p[0]);
  ll reach_right = dist(current, l[i + 1].p[1]);
  ll next_level = dist(l[i + 1].p[0], l[i + 1].p[1]);
  ll sol_left = solve(i + 1, l, 0, memo);
  ll sol_right = solve(i + 1, l, 1, memo);
  return state =
             next_level + min(reach_left + sol_right, reach_right + sol_left);
}
int main() {
  cin.tie(0), cin.sync_with_stdio(0), cout.tie(0), cout.sync_with_stdio(0);
  int n;
  cin >> n;
  vector<pii> v(n);
  for (pii &p : v) cin >> p.first >> p.second;
  sort(v.begin(), v.end(),
       [](pii &a, pii &b) { return get_level(a) < get_level(b); });
  vector<level> levels;
  levels.push_back({0, {{0, 0}, {0, 0}}});
  for (pii &p : v) {
    if (levels.empty() || levels.back().l < get_level(p)) {
      levels.push_back({get_level(p), {p, p}});
    }
    pii &pleft = levels.back().p[0];
    pii &pdown = levels.back().p[1];
    if (p.first < pleft.first ||
        p.first == pleft.first && p.second > pleft.second)
      pleft = p;
    if (p.second < pdown.second ||
        p.second == pdown.second && p.first > pdown.first)
      pdown = p;
  }
  vector<vector<ll>> memo(levels.size(), vector<ll>(2, -1));
  cout << solve(0, levels, 0, memo) << '\n';
  return 0;
}
