#include <bits/stdc++.h>
using namespace std;
map<int, vector<pair<int, int> > > mpp;
map<int, pair<int, int> > mpp2;
map<int, int> mppv;
map<pair<int, int>, long long> dp;
map<int, int> nxt;
long long bolo(int x, int y) {
  int k = max(x, y);
  if (!nxt[k]) {
    return mppv[k];
  }
  if (dp[make_pair(x, y)]) {
    return dp[make_pair(x, y)];
  }
  long long ans = (long long)1e15, now, p, q;
  int n = nxt[k];
  p = mppv[k];
  vector<pair<int, int> > vec = mpp[n];
  for (int i = 0; i < 2; i++) {
    q = abs(vec[i].first - x) + abs(vec[i].second - y);
    now = p + q + bolo(vec[1 - i].first, vec[1 - i].second);
    ans = min(ans, now);
  }
  return dp[make_pair(x, y)] = ans;
}
bool cmp(pair<int, int> a, pair<int, int> b) {
  if (a.first == b.first) return a.second > b.second;
  return a.first < b.first;
}
int main() {
  int n, i, j, k, x, y, l, p, q;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d %d", &x, &y);
    k = max(x, y);
    mpp[k].push_back(make_pair(x, y));
  }
  vector<pair<int, int> > vec;
  for (auto itr = mpp.begin(); itr != mpp.end(); itr++) {
    sort(itr->second.begin(), itr->second.end(), cmp);
  }
  p = 0;
  for (auto itr = mpp.begin(); itr != mpp.end(); itr++) {
    k = itr->first;
    nxt[p] = k;
    vec = itr->second;
    l = vec.size();
    p = abs(vec[0].first - vec[l - 1].first) +
        abs(vec[0].second - vec[l - 1].second);
    mppv[k] = p;
    itr->second.clear();
    itr->second.push_back(vec[0]);
    itr->second.push_back(vec[l - 1]);
    p = k;
  }
  long long ans = bolo(0, 0);
  printf("%lld\n", ans);
  return 0;
}
