#include <bits/stdc++.h>
using namespace std;
inline void Boost() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
const long long inf = 1e18;
long long dist(const pair<int, int> &p, const pair<int, int> &q) {
  return abs(p.first - q.first) + abs(p.second - q.second);
}
map<int, vector<pair<int, int> > > mep;
int main() {
  Boost();
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    int x, y;
    cin >> x >> y;
    mep[max(x, y)].push_back({x, y});
  }
  mep[0].push_back({0, 0});
  for (auto &it : mep) {
    sort(it.second.begin(), it.second.end(),
         [&](const pair<int, int> &p, const pair<int, int> &q) {
           if (p.first == q.first) {
             return p.second > q.second;
           }
           return p.first < q.first;
         });
  }
  vector<vector<long long> > DP(int(mep.size()) + 1, vector<long long>(2, inf));
  DP[0][0] = DP[0][1] = 0;
  int lvl = 0, prev = 0;
  for (auto &it : mep) {
    ++lvl;
    pair<int, int> currL = it.second[0];
    pair<int, int> currR = it.second.back();
    pair<int, int> prevL = mep[prev][0];
    pair<int, int> prevR = mep[prev].back();
    DP[lvl][0] = min(DP[lvl][0],
                     DP[lvl - 1][0] + dist(prevL, currR) + dist(currL, currR));
    DP[lvl][0] = min(DP[lvl][0],
                     DP[lvl - 1][1] + dist(prevR, currR) + dist(currL, currR));
    DP[lvl][1] = min(DP[lvl][1],
                     DP[lvl - 1][0] + dist(prevL, currL) + dist(currL, currR));
    DP[lvl][1] = min(DP[lvl][1],
                     DP[lvl - 1][1] + dist(prevR, currL) + dist(currL, currR));
    prev = it.first;
  }
  cout << min(DP[lvl][0], DP[lvl][1]) << "\n";
  return 0;
}
