#include <bits/stdc++.h>
using namespace std;
long long minx, maxx, miny, maxy;
struct lll {
  long long x, y;
} s;
struct cmp1 {
  bool operator()(lll s1, lll s2) {
    long long min1 = min(min(abs(s1.x - minx), abs(s1.x - maxx)),
                         min(abs(s1.y - miny), abs(s1.y - maxy)));
    long long min2 = min(min(abs(s2.x - minx), abs(s2.x - maxx)),
                         min(abs(s2.y - miny), abs(s2.y - maxy)));
    return min1 > min2;
  }
};
int main() {
  priority_queue<lll, vector<lll>, cmp1> TM;
  minx = 0;
  maxx = 0;
  miny = 0;
  maxy = 0;
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> s.x >> s.y;
    TM.push(s);
  }
  long long sum = 0;
  minx = TM.top().x;
  maxx = TM.top().x;
  miny = TM.top().y;
  maxy = TM.top().y;
  TM.pop();
  while (!TM.empty()) {
    sum += min(min(abs(TM.top().x - minx), abs(TM.top().x - maxx)),
               min(abs(TM.top().y - miny), abs(TM.top().y - maxy)));
    minx = min(minx, TM.top().x);
    maxx = max(maxx, TM.top().x);
    miny = min(miny, TM.top().y);
    maxy = max(maxy, TM.top().y);
    TM.pop();
  }
  cout << sum << endl;
  return 0;
}
