#include <bits/stdc++.h>
using namespace std;
struct node {
  int x, y;
  node(int x, int y) : x(x), y(y) {}
};
int getMax(node p) { return max(p.x, p.y); }
long long getDist(node a, node b) { return abs(a.x - b.x) + abs(a.y - b.y); }
inline bool cmp(node a, node b) { return getMax(a) < getMax(b); }
long long dp[2][203456];
int main() {
  ios::sync_with_stdio(false);
  int n, x, y;
  vector<node> p;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x >> y;
    p.push_back(node(x, y));
  }
  sort(p.begin(), p.end(), cmp);
  vector<int> maxLeftIndex, maxRightIndex;
  int pos = 0;
  int curLeftIndex = 0, curRightIndex = 0;
  for (int i = 1; i < n; i++) {
    if (getMax(p[i]) > getMax(p[i - 1])) {
      maxLeftIndex.push_back(curLeftIndex);
      maxRightIndex.push_back(curRightIndex);
      curLeftIndex = i;
      curRightIndex = i;
      pos++;
    } else {
      if (p[i].x < p[curLeftIndex].x ||
          (p[i].x == p[curLeftIndex].x && p[i].y > p[curLeftIndex].y)) {
        curLeftIndex = i;
      }
      if (p[i].y < p[curRightIndex].y ||
          (p[i].y == p[curRightIndex].y && p[i].x > p[curRightIndex].x)) {
        curRightIndex = i;
      }
    }
  }
  maxLeftIndex.push_back(curLeftIndex);
  maxRightIndex.push_back(curRightIndex);
  pos++;
  dp[0][0] = p[maxRightIndex[0]].x + p[maxRightIndex[0]].y +
             getDist(p[maxLeftIndex[0]], p[maxRightIndex[0]]);
  dp[1][0] = p[maxLeftIndex[0]].x + p[maxLeftIndex[0]].y +
             getDist(p[maxLeftIndex[0]], p[maxRightIndex[0]]);
  for (int i = 1; i < pos; i++) {
    int baseCost = getDist(p[maxLeftIndex[i]], p[maxRightIndex[i]]);
    dp[0][i] =
        min(dp[0][i - 1] + getDist(p[maxLeftIndex[i - 1]], p[maxRightIndex[i]]),
            dp[1][i - 1] +
                getDist(p[maxRightIndex[i - 1]], p[maxRightIndex[i]])) +
        baseCost;
    dp[1][i] =
        min(dp[0][i - 1] + getDist(p[maxLeftIndex[i - 1]], p[maxLeftIndex[i]]),
            dp[1][i - 1] +
                getDist(p[maxRightIndex[i - 1]], p[maxLeftIndex[i]])) +
        baseCost;
  }
  cout << min(dp[0][pos - 1], dp[1][pos - 1]) << endl;
  return 0;
}
