#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 7, N = 1e3 + 7;
vector<int> ver[N], hor[N];
int is[N][N], l[N][N], r[N][N], u[N][N], d[N][N];
signed main() {
  std::ios::sync_with_stdio(0);
  std::cin.tie(0);
  ;
  int n;
  cin >> n;
  vector<int> xs, ys;
  vector<pair<int, int> > a;
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    xs.push_back(x);
    ys.push_back(y);
    a.emplace_back(x, y);
  }
  sort((xs).begin(), (xs).end()), sort((ys).begin(), (ys).end());
  xs.resize(unique((xs).begin(), (xs).end()) - xs.begin()),
      ys.resize(unique((ys).begin(), (ys).end()) - ys.begin());
  for (int i = 0; i < n; i++) {
    pair<int, int> p = a[i];
    int x = lower_bound((xs).begin(), (xs).end(), p.first) - xs.begin();
    int y = lower_bound((ys).begin(), (ys).end(), p.second) - ys.begin();
    ver[x].push_back(y);
    hor[y].push_back(x);
    is[x][y] = i + 1;
    a[i] = {x, y};
  }
  for (int i = 0; i < xs.size(); i++) {
    int cur = -1;
    for (int j = 0; j < ys.size(); j++) {
      d[i][j] = cur;
      if (is[i][j]) cur = j;
    }
    cur = -1;
    for (int j = ys.size() - 1; j >= 0; j--) {
      u[i][j] = cur;
      if (is[i][j]) cur = j;
    }
  }
  for (int j = 0; j < ys.size(); j++) {
    int cur = -1;
    for (int i = 0; i < xs.size(); i++) {
      l[i][j] = cur;
      if (is[i][j]) cur = i;
    }
    cur = -1;
    for (int i = xs.size() - 1; i >= 0; i--) {
      r[i][j] = cur;
      if (is[i][j]) cur = i;
    }
  }
  for (int i = 0; i < xs.size(); i++) sort((ver[i]).begin(), (ver[i]).end());
  for (int j = 0; j < ys.size(); j++) sort((hor[j]).begin(), (hor[j]).end());
  auto ok = [&](int mb) {
    vector<int> p(n + 1), sz(n + 1);
    for (int i = 1; i <= n; i++) p[i] = i, sz[i] = 1;
    function<int(int)> find = [&](int u) {
      return p[u] == u ? u : p[u] = find(p[u]);
    };
    int cnt = 0;
    auto unite = [&](int x, int y) {
      int rx = find(x), ry = find(y);
      if (rx == ry) return;
      if (sz[rx] > sz[ry]) swap(rx, ry);
      p[rx] = ry;
      sz[ry] += sz[rx];
      cnt++;
    };
    for (int i = 0; i < n; i++) {
      int x = a[i].first, y = a[i].second;
      int tt = is[x][y];
      if (l[x][y] != -1 && xs[x] - xs[l[x][y]] <= mb) unite(tt, is[l[x][y]][y]);
      if (r[x][y] != -1 && xs[r[x][y]] - xs[x] <= mb) unite(tt, is[r[x][y]][y]);
      if (u[x][y] != -1 && ys[u[x][y]] - ys[y] <= mb) unite(tt, is[x][u[x][y]]);
      if (d[x][y] != -1 && ys[y] - ys[d[x][y]] <= mb) unite(tt, is[x][d[x][y]]);
    }
    if (cnt == n - 1) return true;
    if (cnt + 4 < n - 1) return false;
    for (int i = 0; i < xs.size(); i++) {
      for (int j = 0; j < ys.size(); j++) {
        if (is[i][j]) continue;
        int x = i, y = j;
        vector<int> v;
        if (l[x][y] != -1 && xs[x] - xs[l[x][y]] <= mb)
          v.push_back(find(is[l[x][y]][y]));
        if (r[x][y] != -1 && xs[r[x][y]] - xs[x] <= mb)
          v.push_back(find(is[r[x][y]][y]));
        if (u[x][y] != -1 && ys[u[x][y]] - ys[y] <= mb)
          v.push_back(find(is[x][u[x][y]]));
        if (d[x][y] != -1 && ys[y] - ys[d[x][y]] <= mb)
          v.push_back(find(is[x][d[x][y]]));
        sort((v).begin(), (v).end());
        int len = unique((v).begin(), (v).end()) - v.begin();
        if (len) {
          if (cnt + len - 1 == n - 1) return true;
        }
      }
    }
    if (cnt == n - 2) {
      for (int i = 0; i < xs.size(); i++) {
        for (int j = 0; j < (int)ver[i].size() - 1; j++) {
          if (ys[ver[i][j + 1]] - ys[ver[i][j]] <= 2LL * mb &&
              find(is[i][ver[i][j + 1]]) != find(is[i][ver[i][j]]))
            return true;
        }
      }
      for (int i = 0; i < ys.size(); i++) {
        for (int j = 0; j < (int)hor[i].size() - 1; j++) {
          if (xs[hor[i][j + 1]] - xs[hor[i][j]] <= 2LL * mb &&
              find(is[hor[i][j + 1]][i]) != find(is[hor[i][j]][i]))
            return true;
        }
      }
    }
    return false;
  };
  int lb = 1, rb = 2e9;
  while (lb <= rb) {
    int mb = (0LL + lb + rb) / 2;
    if (ok(mb))
      rb = mb - 1;
    else
      lb = mb + 1;
  }
  if (lb > (int)2e9)
    cout << -1 << endl;
  else
    cout << lb << endl;
}
