#include <bits/stdc++.h>
const long long MOD = 998244353;
const double ZER = 1e-9;
const double PI = acos(-1);
using namespace std;
struct pt {
  int x, y;
  pt(int _x, int _y) {
    x = _x;
    y = _y;
  }
  pt() {
    x = 0;
    y = 0;
  }
};
const int N = 1e5 + 1;
int n;
map<int, vector<pt> > grp;
vector<int> grpNum;
vector<vector<long long> > dp;
long long dist(pt &a, pt &b) { return abs(a.x - b.x) + abs(a.y - b.y); }
long long calc(int idx, bool who) {
  long long &ret = dp[idx][who];
  if (ret != -1) return ret;
  ret = 0;
  int num = grpNum[idx];
  vector<pt> &v = grp[num];
  pt last;
  if (who) {
    for (int i = 1; i < v.size(); ++i) ret += dist(v[i], v[i - 1]);
    last = v.back();
  } else {
    for (int i = v.size() - 2; i >= 0; --i) ret += dist(v[i], v[i + 1]);
    last = v.front();
  }
  if (idx + 1 < grpNum.size()) {
    num = grpNum[idx + 1];
    long long val = calc(idx + 1, true) + dist(last, grp[num].front());
    long long val1 = calc(idx + 1, false) + dist(last, grp[num].back());
    ret += min(val, val1);
  }
  return ret;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int x, y;
    cin >> x >> y;
    grp[max(x, y)].push_back({x, y});
  }
  for (auto &it : grp) {
    grpNum.push_back(it.first);
    auto &v = it.second;
    sort(v.begin(), v.end(), [](pt &a, pt &b) {
      if (a.x != b.x) return a.x < b.x;
      return a.y > b.y;
    });
  }
  dp.resize(grpNum.size(), vector<long long>(2, -1));
  pt init(0, 0);
  long long val = calc(0, true) + dist(init, grp[grpNum[0]].front());
  long long val1 = calc(0, false) + dist(init, grp[grpNum[0]].back());
  long long res = min(val, val1);
  cout << res << endl;
  return 0;
}
