#include <bits/stdc++.h>
using namespace std;
long long MOD = 1e9 + 7;
long long OO = 1e11 + 1;
const int N = 2e5 + 10, M = 2e5 + 2;
int arr[N];
long long pre[N];
long long dp[N][3];
long long n, m, k, T, ans;
int a, b, c;
int l, r, mid;
map<int, vector<pair<int, int>>> mp;
long long calc(pair<int, int> &f, pair<int, int> &s) {
  int x = abs(f.first - s.first);
  int y = abs(f.second - s.second);
  return x + y;
}
long long Sum(vector<pair<int, int>> &v) {
  long long SU = 0;
  for (int i = 1; i < (int)(v.size()); ++i) SU += calc(v[i], v[i - 1]);
  return SU;
}
long long Solve(int idx, bool lst) {
  if (idx == n) return 0;
  long long &ret = dp[idx][lst];
  if (~ret) return ret;
  auto pf = mp[arr[idx]].front();
  auto ps = mp[arr[idx]].back();
  if (lst) {
    auto p = mp[arr[idx - 1]].front();
    ret = pre[idx] + calc(p, pf) + Solve(idx + 1, 0);
    ret = min(ret, pre[idx] + calc(p, ps) + Solve(idx + 1, 1));
  } else {
    auto p = mp[arr[idx - 1]].back();
    ret = pre[idx] + calc(p, pf) + Solve(idx + 1, 0);
    ret = min(ret, pre[idx] + calc(p, ps) + Solve(idx + 1, 1));
  }
  return ret;
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL), cerr.tie(NULL);
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a >> b;
    mp[max(a, b)].push_back({a, b});
  }
  mp[0].push_back({0, 0});
  n = 0;
  for (auto &it : mp) {
    sort(it.second.begin(), it.second.end(),
         [](pair<int, int> &s, pair<int, int> &f) {
           if (s.first == f.first) return s.second > f.second;
           return s.first < f.first;
         });
    pre[n] = Sum(it.second);
    arr[n++] = it.first;
  }
  memset(dp, -1, sizeof dp);
  cout << Solve(1, 0) << "\n";
}
