#include <bits/stdc++.h>
using namespace std;
int layer(const pair<int, int>& a) { return max(a.first, a.second); }
int dis(const pair<int, int>& a, const pair<int, int>& b) {
  return abs(a.first - b.first) + abs(a.second - b.second);
}
bool cmp(const pair<int, int>& a, const pair<int, int>& b) {
  int ma = layer(a), mb = layer(b);
  if (ma != mb) {
    return ma < mb;
  }
  if (a.first != b.first) {
    return a.first < b.first;
  }
  return a.second > b.second;
}
const int MAXN = 2e5 + 5;
pair<int, int> prs[MAXN];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> prs[i].first >> prs[i].second;
  }
  sort(prs, prs + n, cmp);
  long long pre0 = 0, pre1 = 0;
  pair<int, int> locA, locB;
  locA = locB = make_pair(0, 0);
  for (int i = 0; i < n;) {
    for (int j = i; j < n; j++) {
      if (j == n - 1 || layer(prs[j + 1]) > layer(prs[j])) {
        pair<int, int> a = prs[i], b = prs[j];
        i = j + 1;
        long long tmp1 = min(pre0 + dis(locA, b) + dis(b, a),
                             pre1 + dis(locB, b) + dis(b, a));
        long long tmp2 = min(pre1 + dis(locB, a) + dis(a, b),
                             pre0 + dis(locA, a) + dis(a, b));
        pre0 = tmp1;
        pre1 = tmp2;
        locA = a;
        locB = b;
      }
    }
  }
  cout << min(pre0, pre1) << endl;
  return 0;
}
