#include <bits/stdc++.h>
using namespace std;
int dx[4] = {0, 0, 1, -1};
int dy[4] = {1, -1, 0, 0};
const int N = 3e5 + 5, NN = 10, MOD = 1e9 + 7;
int n;
vector<long long> val;
vector<pair<pair<long long, long long>, pair<long long, long long>>> v;
long long mem[N][2];
bool comp(pair<long long, long long> a, pair<long long, long long> b) {
  if (a.first == b.first) return a.second > b.second;
  return a.first < b.first;
}
long long calc(pair<long long, long long> a, pair<long long, long long> b) {
  return (abs(a.first - b.first) + abs(a.second - b.second));
}
long long solve(int pos, bool b) {
  if (pos == v.size() - 1) return val[pos];
  long long& ret = mem[pos][b];
  if (ret != -1) return ret;
  ret = 1e17;
  if (b) {
    ret = solve(pos + 1, 1) + calc(v[pos].second, v[pos + 1].first);
    ret = min(ret, solve(pos + 1, 0) + calc(v[pos].second, v[pos + 1].second));
  } else {
    ret = solve(pos + 1, 1) + calc(v[pos].first, v[pos + 1].first);
    ret = min(ret, solve(pos + 1, 0) + calc(v[pos].first, v[pos + 1].second));
  }
  return ret = ret + val[pos];
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n;
  map<int, vector<pair<long long, long long>>> mp;
  int a, b;
  for (int(i) = 0; i < (n); i++) {
    cin >> a >> b;
    mp[max(a, b)].push_back({a, b});
  }
  int c = 0;
  for (auto& i : mp) {
    c++;
    sort((i.second).begin(), (i.second).end(), comp);
  }
  long long z = 0;
  v.push_back({{z, z}, {z, z}});
  val.push_back(0);
  for (auto& i : mp) {
    long long sum = 0;
    for (int(x) = 1; x <= (i.second.size() - 1); x++) {
      sum += calc(i.second[x], i.second[x - 1]);
    }
    val.push_back(sum);
    v.push_back({i.second[0], i.second[i.second.size() - 1]});
  }
  memset(mem, -1, sizeof mem);
  long long ans = solve(0, 0);
  cout << ans;
}
