#include <bits/stdc++.h>
using namespace std;
long long int ll1[500005], rr[500005], lr[500005], rl[500005];
map<long long int, vector<tuple<long long int, long long int, long long int>>>
    v;
vector<pair<long long int, long long int>> pts[500005];
long long int dis(long long int i, long long int l, long long int r,
                  long long int l1) {
  long long int ans = abs(pts[i + 1][r].first - pts[i][l].first) +
                      abs(pts[i + 1][r].second - pts[i][l].second);
  ans += abs(pts[i + 1][r].first - pts[i + 1][l1].first) +
         abs(pts[i + 1][r].second - pts[i + 1][l1].second);
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n;
  cin >> n;
  for (int i = 0; i < int(n); ++i) {
    long long int x, y;
    cin >> x >> y;
    v[max(x, y)].push_back(make_tuple(x - y, x, y));
  }
  long long int cnt = 1;
  pts[0].push_back({0, 0});
  for (auto i : v) {
    sort(i.second.begin(), i.second.end());
    for (auto j : i.second) {
      long long int d, x, y;
      tie(d, x, y) = j;
      pts[cnt].push_back({x, y});
    }
    cnt++;
  }
  for (int i = 0; i < int(cnt - 1); ++i) {
    ll1[i + 1] =
        min(ll1[i], rl[i]) + dis(i, 0, (int)(pts[i + 1].size()) - 1, 0);
    lr[i + 1] = min(ll1[i], rl[i]) + dis(i, 0, 0, (int)(pts[i + 1].size()) - 1);
    rl[i + 1] = min(lr[i], rr[i]) + dis(i, (int)(pts[i].size()) - 1,
                                        (int)(pts[i + 1].size()) - 1, 0);
    rr[i + 1] = min(lr[i], rr[i]) + dis(i, (int)(pts[i].size()) - 1, 0,
                                        (int)(pts[i + 1].size()) - 1);
  }
  long long int ans =
      min(ll1[cnt - 1], min(rr[cnt - 1], min(lr[cnt - 1], rl[cnt - 1])));
  cout << ans;
  return 0;
}
