#include <bits/stdc++.h>
using namespace std;
constexpr int kN = int(2E3 + 10), kInf = int(2E9 + 10);
int x[kN], y[kN], p[kN], vsz, xsz[kN], ysz[kN], cnt[kN], psz[kN], Clock, idx;
vector<int> v;
vector<pair<int, int>> X[kN], Y[kN], vt[kN * kN];
pair<int, int> points[kN * kN];
int Find(int n) { return n == p[n] ? n : p[n] = Find(p[n]); }
int ABS(int n) { return n >= 0 ? n : -n; }
bool Union(int l, int r) {
  l = Find(l), r = Find(r);
  if (l == r) return false;
  if (psz[l] < psz[r]) swap(l, r);
  p[r] = l;
  psz[l] += psz[r];
  return true;
}
vector<pair<int, int>> connect(int px, int py) {
  int npx = lower_bound(v.begin(), v.end(), px) - v.begin(),
      npy = lower_bound(v.begin(), v.end(), py) - v.begin(), tmp;
  vector<pair<int, int>> vec;
  if (px == v[npx] && xsz[npx]) {
    if (X[npx][0].first >= py)
      vec.push_back({X[npx][0].second, X[npx][0].first - py});
    else if (X[npx].back().first < py)
      vec.push_back({X[npx].back().second, py - X[npx].back().first});
    else {
      tmp = lower_bound(X[npx].begin(), X[npx].end(), make_pair(py, 0)) -
            X[npx].begin();
      vec.push_back({X[npx][tmp].second, X[npx][tmp].first - py});
      vec.push_back({X[npx][tmp - 1].second, py - X[npx][tmp - 1].first});
    }
  }
  if (py == v[npy] && ysz[npy]) {
    if (Y[npy][0].first >= px)
      vec.push_back({Y[npy][0].second, Y[npy][0].first - px});
    else if (Y[npy].back().first < px)
      vec.push_back({Y[npy].back().second, px - Y[npy].back().first});
    else {
      tmp = lower_bound(Y[npy].begin(), Y[npy].end(), make_pair(px, 0)) -
            Y[npy].begin();
      vec.push_back({Y[npy][tmp].second, Y[npy][tmp].first - px});
      vec.push_back({Y[npy][tmp - 1].second, px - Y[npy][tmp - 1].first});
    }
  }
  return vec;
}
vector<tuple<int, int, int>> edges;
bool ok(int lim, int n) {
  int tmp;
  for (int i = 1; i <= n; i++) p[i] = i;
  for (int i = 1; i <= n; i++) psz[i] = 1;
  for (tuple<int, int, int> i : edges)
    if (get<0>(i) <= lim) {
      if (Union(get<1>(i), get<2>(i))) n--;
    } else
      break;
  if (n == 1) return true;
  for (int i = 0; i < idx; i++) {
    tmp = 0;
    Clock++;
    for (pair<int, int> j : vt[i])
      if (j.second <= lim && cnt[Find(j.first)] != Clock) {
        tmp++;
        cnt[Find(j.first)] = Clock;
      }
    if (n == tmp) return true;
  }
  return false;
}
int main() {
  int n, px, py;
  long long int l = 0, r = kInf, mid;
  vector<pair<int, int>> points;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d%d", &x[i], &y[i]);
  for (int i = 1; i <= n; i++) v.push_back(x[i]), v.push_back(y[i]);
  sort(v.begin(), v.end());
  v.resize(unique(v.begin(), v.end()) - v.begin());
  for (int i = 1; i <= n; i++)
    X[lower_bound(v.begin(), v.end(), x[i]) - v.begin()].push_back({y[i], i});
  for (int i = 1; i <= n; i++)
    Y[lower_bound(v.begin(), v.end(), y[i]) - v.begin()].push_back({x[i], i});
  vsz = int(v.size());
  for (int i = 0; i < vsz; i++) sort(X[i].begin(), X[i].end());
  for (int i = 0; i < vsz; i++) xsz[i] = int(X[i].size());
  for (int i = 0; i < vsz; i++) sort(Y[i].begin(), Y[i].end());
  for (int i = 0; i < vsz; i++) ysz[i] = int(Y[i].size());
  for (int i = 0; i < vsz; i++) {
    for (int j = 1; j < xsz[i]; j++)
      edges.push_back({X[i][j].first - X[i][j - 1].first, X[i][j].second,
                       X[i][j - 1].second});
    for (int j = 1; j < ysz[i]; j++)
      edges.push_back({Y[i][j].first - Y[i][j - 1].first, Y[i][j].second,
                       Y[i][j - 1].second});
  }
  sort(edges.begin(), edges.end());
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++) {
      if (x[i] == x[j])
        points.push_back({x[i], (y[i] + y[j]) >> 1});
      else if (y[i] == y[j])
        points.push_back({(x[i] + x[j]) >> 1, y[i]});
      else {
        points.push_back({x[i], y[j]});
        points.push_back({x[j], y[i]});
      }
    }
  sort(points.begin(), points.end());
  points.resize(unique(points.begin(), points.end()) - points.begin());
  idx = int(points.size());
  for (int i = 0; i < idx; i++)
    vt[i] = connect(points[i].first, points[i].second);
  while (r - l > 1) {
    mid = (l + r) >> 1;
    if (ok(mid, n))
      r = mid;
    else
      l = mid;
  }
  if (r == kInf) r = -1;
  printf("%lld\n", r);
}
