#include <bits/stdc++.h>
using namespace std;
int n;
int xi[200005], yi[200005];
set<int> S;
vector<int> comp;
vector<int> srtd[200005];
long long dp[200005][2];
bool cmp(int a, int b) {
  if (xi[a] == xi[b]) return yi[a] > yi[b];
  return xi[a] < xi[b];
}
long long dist(int a, int b) {
  long long x = xi[a] - xi[b];
  long long y = yi[a] - yi[b];
  if (x < 0) x = -x;
  if (y < 0) y = -y;
  return x + y;
}
long long f(int pos, int L) {
  if (pos == comp.size()) return 0;
  long long &ans = dp[pos][L];
  if (ans != -1) return ans;
  ans = 1e18;
  long long sum = 0;
  for (int i = 1; i < srtd[pos].size(); i++) {
    sum += dist(srtd[pos][i - 1], srtd[pos][i]);
  }
  if (L == 0) {
    ans = min(ans, sum + dist(srtd[pos - 1][0], srtd[pos][0]) + f(pos + 1, 1));
    ans = min(ans,
              sum + dist(srtd[pos - 1][0], srtd[pos].back()) + f(pos + 1, 0));
  } else {
    ans = min(ans,
              sum + dist(srtd[pos - 1].back(), srtd[pos][0]) + f(pos + 1, 1));
    ans = min(ans, sum + dist(srtd[pos - 1].back(), srtd[pos].back()) +
                       f(pos + 1, 0));
  }
  return ans;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &xi[i], &yi[i]);
    int v = max(xi[i], yi[i]);
    S.insert(v);
  }
  S.insert(0);
  for (auto it : S) comp.push_back(it);
  for (int i = 1; i <= n; i++) {
    int v = max(xi[i], yi[i]);
    int pos = lower_bound(comp.begin(), comp.end(), v) - comp.begin();
    srtd[pos].push_back(i);
  }
  srtd[0].push_back(0);
  for (int i = 0; i < comp.size(); i++)
    sort(srtd[i].begin(), srtd[i].end(), cmp);
  memset(dp, -1, sizeof(dp));
  long long ans = 1e18;
  ans = f(1, 0);
  printf("%lld\n", ans);
  return 0;
}
