#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
int n, x, y, ans1 = 0, ans2 = 0;
struct edge {
  int i, x, y;
} l[MAXN];
bool cmp1(edge a, edge b) {
  if (a.x == b.x)
    return a.y < b.y;
  else
    return a.x < b.x;
}
bool cmp2(edge a, edge b) {
  if (a.y == b.y)
    return a.x < b.x;
  else
    return a.y < b.y;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d %d", &l[i].x, &l[i].y), l[i].i = i;
  sort(l + 1, l + n + 1, cmp1);
  for (int i = 2; i < n; i++)
    ans1 += min(abs(l[i].x - l[i - 1].x), abs(l[i].y - l[i - 1].y));
  ans1 += min(min(abs(l[n].x - l[1].x), abs(l[n].y - l[1].y)),
              min(abs(l[n].y - l[n - 1].y), abs(l[n].x - l[n - 1].x)));
  sort(l + 1, l + n + 1, cmp2);
  for (int i = 2; i < n; i++)
    ans2 += min(abs(l[i].x - l[i - 1].x), abs(l[i].y - l[i - 1].y));
  ans1 += min(min(abs(l[n].x - l[1].x), abs(l[n].y - l[1].y)),
              min(abs(l[n].y - l[n - 1].y), abs(l[n].x - l[n - 1].x)));
  printf("%d\n", min(ans1, ans2));
  return 0;
}
