#include <bits/stdc++.h>
using namespace std;
template <class T>
void _R(T &x) {
  cin >> x;
}
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template <class T, class... U>
void R(T &head, U &...tail) {
  _R(head);
  R(tail...);
}
template <class T>
void _W(const T &x) {
  cout << x;
}
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template <class T, class U>
void _W(const pair<T, U> &x) {
  _W(x.first);
  putchar(' ');
  _W(x.second);
}
template <class T>
void _W(const vector<T> &x) {
  for (auto i = x.begin(); i != x.end(); _W(*i++))
    if (i != x.cbegin()) putchar(' ');
}
void W() {}
template <class T, class... U>
void W(const T &head, const U &...tail) {
  _W(head);
  putchar(sizeof...(tail) ? ' ' : '\n');
  W(tail...);
}
int MOD = 1e9 + 7;
void ADD(long long &x, long long v) {
  x = (x + v) % MOD;
  if (x < 0) x += MOD;
}
const int SIZE = 1 << 20;
struct Union_Find {
  int d[1234567], num[1234567];
  vector<pair<int *, int>> bk;
  void comeback() {
    for (int i = ((int)(bk).size()) - 1; i >= 0; i--) {
      *bk[i].first = bk[i].second;
    }
    bk.clear();
  }
  void init(int n) {
    for (int i = 0; i < (n); ++i) d[i] = i, num[i] = 1;
  }
  int find(int x) {
    while (x != d[x]) x = d[x];
    return x;
  }
  bool is_root(int x) { return d[x] == x; }
  bool uu(int x, int y, bool save = 0) {
    x = find(x);
    y = find(y);
    if (x == y) return 0;
    if (num[x] > num[y]) {
      if (save) {
        bk.emplace_back(make_pair(&num[x], num[x]));
        bk.emplace_back(make_pair(&num[y], num[y]));
      }
      swap(x, y);
    }
    if (save) {
      bk.emplace_back(make_pair(&num[y], num[y]));
      bk.emplace_back(make_pair(&d[x], d[x]));
    }
    num[y] += num[x];
    d[x] = y;
    return 1;
  }
} U;
int x[4096], y[4096];
vector<int> xx, yy;
int id[2048][2048], dir[2048][2048][4];
const int RIGHT = 0;
const int LEFT = 2;
const int UP = 1;
const int DOWN = 3;
int dis(int u, int v) {
  ;
  return abs(xx[x[u]] - xx[x[v]]) + abs(yy[y[u]] - yy[y[v]]);
}
struct EDGE {
  int x, y, v;
  EDGE(int x = 0, int y = 0, int v = 0) : x(x), y(y), v(v) {}
  void get_dis() { v = dis(x, y); }
  bool operator<(const EDGE &b) const { return v < b.v; }
} e[8192];
int n;
void solve() {
  memset((id), -1, sizeof((id)));
  for (int i = 0; i < (n); ++i) {
    xx.emplace_back(x[i]);
    yy.emplace_back(y[i]);
  }
  (sort(xx.begin(), xx.end()),
   xx.resize(distance(xx.begin(), unique(xx.begin(), xx.end()))));
  {
    int xn = ((int)(xx).size());
    for (int i = (1); i < (xn); ++i) {
      if (xx[i] != xx[i - 1] + 1) {
        xx.emplace_back((xx[i] + xx[i - 1]) / 2);
      }
    }
    (sort(xx.begin(), xx.end()),
     xx.resize(distance(xx.begin(), unique(xx.begin(), xx.end()))));
  }
  (sort(yy.begin(), yy.end()),
   yy.resize(distance(yy.begin(), unique(yy.begin(), yy.end()))));
  {
    int yn = ((int)(yy).size());
    for (int i = (1); i < (yn); ++i) {
      if (yy[i] != yy[i - 1] + 1) {
        yy.emplace_back((yy[i] + yy[i - 1]) / 2);
      }
    }
    (sort(yy.begin(), yy.end()),
     yy.resize(distance(yy.begin(), unique(yy.begin(), yy.end()))));
  }
  for (int i = 0; i < (n); ++i) {
    x[i] = (lower_bound(xx.begin(), xx.end(), x[i]) - xx.begin());
    y[i] = (lower_bound(yy.begin(), yy.end(), y[i]) - yy.begin());
    id[x[i]][y[i]] = i;
  }
  for (int i = 0; i < (2048); ++i) {
    int lt = -1;
    for (int j = 0; j < (2048); ++j) {
      dir[i][j][LEFT] = lt;
      if (id[i][j] != -1) lt = id[i][j];
    }
    lt = -1;
    for (int j = 2047; j >= 0; j--) {
      dir[i][j][RIGHT] = lt;
      if (id[i][j] != -1) lt = id[i][j];
    }
  }
  for (int j = 0; j < (2048); ++j) {
    int lt = -1;
    for (int i = 0; i < (2048); ++i) {
      dir[i][j][UP] = lt;
      if (id[i][j] != -1) lt = id[i][j];
    }
    lt = -1;
    for (int i = 2047; i >= 0; i--) {
      dir[i][j][DOWN] = lt;
      if (id[i][j] != -1) lt = id[i][j];
    }
  }
  int en = 0;
  for (int i = 0; i < (2048); ++i)
    for (int j = 0; j < (2048); ++j) {
      if (id[i][j] == -1) continue;
      for (int k = 0; k < (2); ++k) {
        if (dir[i][j][k] == -1) continue;
        e[en].x = id[i][j];
        e[en].y = dir[i][j][k];
        e[en].get_dis();
        en++;
      }
    }
  sort(e, e + en);
  int it = 0;
  U.init(n + 1);
  int gg = n;
  int ma = 0;
  while (it < en && gg > 4) {
    if (U.uu(e[it].x, e[it].y)) {
      ma = e[it].v;
      gg--;
    }
    it++;
  }
  vector<EDGE> AA;
  int saved_gg = gg;
  while (it < en && gg > 1) {
    if (U.uu(e[it].x, e[it].y, 1)) {
      AA.emplace_back(e[it]);
      gg--;
    }
    it++;
  }
  U.comeback();
  EDGE tmp[8];
  int an = MOD * 2;
  for (int i = 0; i < (((int)(xx).size())); ++i)
    for (int j = 0; j < (((int)(yy).size())); ++j) {
      if (id[i][j] != -1) continue;
      int tn = 0;
      x[n] = i;
      y[n] = j;
      for (int k = 0; k < (4); ++k) {
        if (dir[i][j][k] == -1) continue;
        EDGE me(n, dir[i][j][k]);
        me.get_dis();
        tmp[tn++] = me;
      }
      for (auto me : AA) tmp[tn++] = me;
      sort(tmp, tmp + tn);
      int tmp_ma = 0;
      int tmp_gg = saved_gg + 1;
      for (int k = 0; k < (tn); ++k) {
        if (U.uu(tmp[k].x, tmp[k].y, 1)) {
          tmp_gg--;
          tmp_ma = tmp[k].v;
        }
      }
      if (tmp_gg == 1) {
        an = min(an, max(tmp_ma, ma));
      }
      U.comeback();
    }
  {
    int tn = 0;
    for (auto me : AA) tmp[tn++] = me;
    sort(tmp, tmp + tn);
    int tmp_ma = 0;
    int tmp_gg = saved_gg;
    for (int k = 0; k < (tn); ++k) {
      if (U.uu(tmp[k].x, tmp[k].y, 1)) {
        tmp_gg--;
        tmp_ma = tmp[k].v;
      }
    }
    if (tmp_gg == 1) {
      an = min(an, max(tmp_ma, ma));
    }
  }
  if (an == MOD * 2)
    W(-1);
  else
    W(an);
}
void input() {
  R(n);
  for (int i = 0; i < (n); ++i) R(x[i], y[i]);
}
int main() {
  {
    input();
    solve();
  }
  return 0;
}
