#include <bits/stdc++.h>
using namespace std;
struct point_t {
  int x, y;
  point_t() : x(0), y(0) {}
  int level() const { return max(x, y); }
  bool operator<(const point_t& rhs) const {
    if (x < rhs.x) return true;
    if (x > rhs.x) return false;
    return y > rhs.y;
  }
};
istream& operator>>(istream& is, point_t& point) {
  return is >> point.x >> point.y;
}
ostream& operator<<(ostream& os, const point_t& point) {
  return os << "(" << point.x << "," << point.y << ")";
}
long long dist(const point_t& lhs, const point_t& rhs) {
  return abs((long long)lhs.x - rhs.x) + abs((long long)lhs.y - rhs.y);
}
int main() {
  map<int, pair<point_t, point_t>> m;
  int n;
  cin >> n;
  while (n--) {
    point_t point;
    cin >> point;
    int level = point.level();
    if (m.find(level) == m.end()) {
      m[level] = make_pair(point, point);
    } else {
      auto& v = m[level];
      v.first = min(v.first, point);
      v.second = max(v.second, point);
    }
  }
  point_t p0, p1;
  long long d0 = 0, d1 = 0;
  for (const auto& mi : m) {
    point_t pp0 = mi.second.first, pp1 = mi.second.second;
    long long d = dist(pp0, pp1);
    long long dd0 = min(d0 + dist(p0, pp1), d1 + dist(p1, pp1)) + d;
    long long dd1 = min(d0 + dist(p0, pp0), d1 + dist(p1, pp0)) + d;
    p0 = pp0;
    p1 = pp1;
    d0 = dd0;
    d1 = dd1;
  }
  cout << min(d0, d1) << endl;
  return 0;
}
