#include <bits/stdc++.h>
using namespace std;
using ll = long long;
struct pt {
  int x, y;
  bool operator<(const pt &o) const {
    if (y != o.y)
      return y > o.y;
    else
      return x < o.x;
  }
};
ll dist(pt &a, pt &b) { return abs(a.x - b.x) + abs(a.y - b.y); }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  map<int, vector<pt>> mp_pts_by_lvl;
  vector<vector<pt>> pts_by_lvl;
  for (int i = 0; i < n; i++) {
    pt p;
    cin >> p.x >> p.y;
    mp_pts_by_lvl[max(p.x, p.y)].push_back(p);
  }
  mp_pts_by_lvl[0].push_back({0, 0});
  for (auto &it : mp_pts_by_lvl) {
    vector<pt> &pts = it.second;
    sort(pts.begin(), pts.end());
    pts_by_lvl.push_back(pts);
  }
  ll dp1 = 0, dp2 = 0;
  for (int i = 1; i < (int)pts_by_lvl.size(); i++) {
    vector<pt> &prv = pts_by_lvl[i - 1];
    vector<pt> &cur = pts_by_lvl[i];
    ll dp1_nw =
        min(dp1 + dist(prv.front(), cur.back()) + dist(cur.back(), cur.front()),
            dp2 + dist(prv.back(), cur.back()) + dist(cur.back(), cur.front()));
    ll dp2_nw = min(
        dp1 + dist(prv.front(), cur.front()) + dist(cur.front(), cur.back()),
        dp2 + dist(prv.back(), cur.front()) + dist(cur.front(), cur.back()));
    dp1 = dp1_nw;
    dp2 = dp2_nw;
  }
  cout << min(dp1, dp2) << endl;
  return 0;
}
