#include <bits/stdc++.h>
using namespace std;
class f {
 public:
  bool operator()(pair<int, int> a, pair<int, int> b) {
    if (a.first != b.first) {
      return a.first >= b.first;
    } else
      return a.second <= b.second;
  }
};
int main() {
  int n;
  cin >> n;
  map<int, vector<pair<int, int>>> m;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    int r = max(a, b);
    m[r].push_back(make_pair(a, b));
  }
  vector<vector<long long>> V;
  for (auto it = m.begin(); it != m.end(); it++) {
    set<pair<int, int>, f> s;
    for (int i = 0; i < it->second.size(); i++) {
      s.insert(it->second.at(i));
    }
    long long l = 0;
    pair<int, int> st = *s.begin();
    s.erase(s.begin());
    pair<int, int> pre = st;
    for (auto it1 = s.begin(); it1 != s.end(); it1++) {
      l += abs(pre.first - it1->first) + abs(pre.second - it1->second);
      pre = *it1;
    }
    pair<int, int> end;
    if (s.size() == 0)
      end = st;
    else {
      auto j = s.end();
      j--;
      end = *j;
    }
    vector<long long> v;
    v.push_back((long long)st.first);
    v.push_back((long long)st.second);
    v.push_back((long long)end.first);
    v.push_back((long long)end.second);
    v.push_back(l);
    V.push_back(v);
  }
  pair<long long, long long> pre;
  pre.first = 0;
  pre.second = 0;
  for (int i = 0; i < V.size(); i++) {
    pair<int, int> p1, p2, p3, p4;
    if (i == 0) {
      p1 = make_pair(0, 0);
      p2 = make_pair(0, 0);
    } else {
      p1 = make_pair(V[i - 1][0], V[i - 1][1]);
      p2 = make_pair(V[i - 1][2], V[i - 1][3]);
    }
    p3 = make_pair(V[i][0], V[i][1]);
    p4 = make_pair(V[i][2], V[i][3]);
    long long leftmin =
        min(pre.first + abs(p1.first - p4.first) + abs(p1.second - p4.second),
            pre.second + abs(p2.first - p4.first) +
                abs(p2.second - p4.second)) +
        V[i][4];
    long long rightmin =
        min(pre.first + abs(p1.first - p3.first) + abs(p1.second - p3.second),
            pre.second + abs(p2.first - p3.first) +
                abs(p2.second - p3.second)) +
        V[i][4];
    pre = make_pair(leftmin, rightmin);
  }
  cout << min(pre.first, pre.second);
}
