#include <bits/stdc++.h>
using namespace std;
template <class T>
ostream &operator<<(ostream &os, const pair<T, T> &p) {
  return os << "(" << p.first << "," << p.second << ")";
}
template <class T>
ostream &operator<<(ostream &os, const pair<const T, T> &p) {
  return os << "(" << p.first << "," << p.second << ")";
}
template <class T>
ostream &operator<<(ostream &os, const array<T, 3> &p) {
  return os << "(" << p[0] << "," << p[1] << "," << p[2] << ")";
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &p) {
  for (auto x : p) os << x << ' ';
  return os;
}
const double EPS = 1e-9, PI = acos(-1);
const long long LINF = 0x3f3f3f3f3f3f3f3f, mod = 1e9 + 7;
const long long INF = 0x3f3f3f3f, SZ = 2e5 + 10;
bool comp(pair<long long, long long> a, pair<long long, long long> b) {
  if (a.second == b.second)
    return a.first < b.first;
  else
    return a.second > b.second;
}
long long dist(pair<long long, long long> a, pair<long long, long long> b) {
  return abs(a.second - b.second) + abs(a.first - b.first);
}
map<long long, vector<pair<long long, long long> > > v;
vector<long long> res[2];
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    long long a, b;
    cin >> a >> b;
    v[max(a, b)].push_back({a, b});
  }
  for (auto &p : v) sort((p.second).begin(), (p.second).end(), comp);
  auto it = v.begin();
  res[0] = {0, 0};
  res[1] = {0, 0};
  for (long long i = 0; i < it->second.size(); i++) {
    if (i == 0) {
      res[1][0] = dist(it->second[i], {0LL, 0LL});
    } else {
      res[1][0] += dist(it->second[i], it->second[i - 1]);
    }
  }
  for (long long i = it->second.size() - 1; i >= 0; i--) {
    if (i == it->second.size() - 1) {
      res[1][1] = dist(it->second[i], {0LL, 0LL});
    } else {
      res[1][1] += dist(it->second[i], it->second[i + 1]);
    }
  }
  swap(res[0], res[1]);
  auto ant = it;
  it++;
  for (; it != v.end(); it++) {
    for (long long i = 0; i < it->second.size(); i++) {
      if (i == 0) {
        res[1][0] = min(res[0][0] + dist(it->second[i], ant->second.back()),
                        res[0][1] + dist(it->second[i], ant->second.front()));
      } else {
        res[1][0] += dist(it->second[i], it->second[i - 1]);
      }
    }
    for (long long i = it->second.size() - 1; i >= 0; i--) {
      if (i == it->second.size() - 1) {
        res[1][1] = min(res[0][0] + dist(it->second[i], ant->second.back()),
                        res[0][1] + dist(it->second[i], ant->second.front()));
      } else {
        res[1][1] += dist(it->second[i], it->second[i + 1]);
      }
    }
    swap(res[0], res[1]);
    ant++;
  }
  cout << min(res[0][0], res[0][1]) << '\n';
  return 0;
}
