#include <bits/stdc++.h>
using namespace std;
struct punkt {
  long long x, y;
};
void haha(punkt &c) {
  c.x = 0;
  c.y = 0;
}
bool cmp(punkt a, punkt b) {
  if (a.x != b.x) return b.x > a.x;
  return b.y < a.y;
}
long long iloczyn(punkt a, punkt b) { return abs(a.x - b.x) + abs(b.y - a.y); }
map<int, vector<punkt> > m;
int n;
long long dp[2][2];
long long inf = 1e18;
int main() {
  cin >> n;
  for (int i = 0; n > i; i++) {
    punkt c;
    cin >> c.x >> c.y;
    m[max(c.x, c.y)].push_back(c);
  }
  for (auto &it : m) {
    sort(it.second.begin(), it.second.end(), cmp);
  }
  dp[0][0] = 0;
  dp[0][1] = 0;
  punkt p1, p2;
  haha(p1);
  haha(p2);
  for (auto it : m) {
    punkt a = it.second[0];
    punkt b = it.second.back();
    dp[1][0] = dp[1][1] = inf;
    dp[1][0] = min(dp[1][0], dp[0][0] + iloczyn(p1, b) + iloczyn(a, b));
    dp[1][0] = min(dp[1][0], dp[0][1] + iloczyn(p2, b) + iloczyn(a, b));
    dp[1][1] = min(dp[1][1], dp[0][0] + iloczyn(p1, a) + iloczyn(a, b));
    dp[1][1] = min(dp[1][1], dp[0][1] + iloczyn(p2, a) + iloczyn(a, b));
    p1 = a;
    p2 = b;
    dp[0][0] = dp[1][0];
    dp[0][1] = dp[1][1];
  }
  cout << min(dp[1][0], dp[1][1]);
  return 0;
}
