#include <bits/stdc++.h>
using namespace std;
template <typename T>
using v = vector<T>;
int main() {
  int N;
  cin >> N;
  vector<int> x(N), y(N);
  int minx = 2000000000, miny = 2000000000, maxx = 0, maxy = 0;
  for (int i = (int)(0); i < (int)(N); i++) {
    cin >> x[i] >> y[i];
    minx = min(minx, x[i]);
    maxx = max(maxx, x[i]);
    miny = min(miny, y[i]);
    maxy = max(maxy, y[i]);
  }
  vector<int> sx = x;
  vector<int> sy = y;
  sort(sx.begin(), sx.end());
  sort(sy.begin(), sy.end());
  long long ans = 0;
  int mind = 2000000000;
  for (int i = (int)(0); i < (int)(N); i++) {
    int dx = 0, dy = 0;
    if (x[i] == minx) {
      dx = sx[1] - x[i];
    } else if (x[i] == maxx) {
      dx = x[i] - sx[N - 2];
    } else {
      dx = x[i] - *(upper_bound(sx.begin(), sx.end(), x[i]) - 2);
      dx = min(dx, *(lower_bound(sx.begin(), sx.end(), x[i]) + 1) - x[i]);
    }
    if (y[i] == miny) {
      dy = sy[1] - y[i];
    } else if (y[i] == maxy) {
      dy = y[i] - sy[N - 2];
    } else {
      dy = y[i] - *(upper_bound(sy.begin(), sy.end(), y[i]) - 2);
      dy = min(dy, *(lower_bound(sy.begin(), sy.end(), y[i]) + 1) - y[i]);
    }
    ans += min(dx, dy);
    mind = min(mind, min(dx, dy));
  }
  cout << ans - mind << endl;
  return 0;
}
