#include <bits/stdc++.h>
using namespace std;
struct point_t_comp {
  bool operator()(const pair<int64_t, int64_t>& a,
                  const pair<int64_t, int64_t>& b) {
    return (a.first < b.first) || (a.first == b.first && a.second > b.second);
  }
};
int main() {
  int n;
  cin >> n;
  map<int, set<pair<int64_t, int64_t>, point_t_comp> > point_map;
  for (int i = 0; i < n; i++) {
    pair<int64_t, int64_t> point;
    cin >> point.first >> point.second;
    int level = max(point.first, point.second);
    point_map[level].emplace(point);
  }
  point_map[0].emplace(pair<int64_t, int64_t>(0, 0));
  uint64_t distance1 = 0, distance2 = 0;
  for (map<int, set<pair<int64_t, int64_t>, point_t_comp> >::iterator it =
           point_map.begin();
       it != point_map.end(); it++) {
    int level = it->first;
    set<pair<int64_t, int64_t>, point_t_comp> points = it->second;
    pair<int64_t, int64_t> point1(*points.begin());
    pair<int64_t, int64_t> point2(*points.rbegin());
    it++;
    if (it == point_map.end()) break;
    int next_level = it->first;
    set<pair<int64_t, int64_t>, point_t_comp> next_points = it->second;
    it--;
    pair<int64_t, int64_t> point3(*next_points.begin());
    pair<int64_t, int64_t> point4(*next_points.rbegin());
    uint64_t d3_4 =
        abs(point4.first - point3.first) + abs(point4.second - point3.second);
    uint64_t d1_3 = distance1 + abs(point4.first - point1.first) +
                    abs(point4.second - point1.second) + d3_4;
    uint64_t d2_3 = distance2 + abs(point4.first - point2.first) +
                    abs(point4.second - point2.second) + d3_4;
    uint64_t d3 = min(d1_3, d2_3);
    uint64_t d1_4 = distance1 + abs(point3.first - point1.first) +
                    abs(point3.second - point1.second) + d3_4;
    uint64_t d2_4 = distance2 + abs(point3.first - point2.first) +
                    abs(point3.second - point2.second) + d3_4;
    uint64_t d4 = min(d1_4, d2_4);
    distance1 = d3;
    distance2 = d4;
  }
  cout << min(distance1, distance2) << endl;
}
