#include <bits/stdc++.h>
using namespace std;
map<int, map<int, int>> koordsXY, koordsYX;
vector<vector<pair<int, int>>> g;
vector<pair<int, int>> v;
vector<bool> volt;
vector<int> csop;
int table[4][1000];
int ert[4] = {};
void Bejar(int akt, int c, int t) {
  volt[akt] = true;
  csop[akt] = c;
  for (pair<int, int> temp : g[akt])
    if (!volt[temp.first] && temp.second <= t) Bejar(temp.first, c, t);
  return;
}
int Megold(int x, int y) {
  int ret = (int)2e9 + 1;
  vector<pair<int, int>> kapcs;
  auto it = koordsXY[x].lower_bound(y);
  if (it != koordsXY[x].end())
    kapcs.push_back(make_pair(it->second, it->first - y));
  if (it != koordsXY[x].begin())
    kapcs.push_back(make_pair(prev(it)->second, y - prev(it)->first));
  it = koordsYX[y].lower_bound(x);
  if (it != koordsYX[y].end())
    kapcs.push_back(make_pair(it->second, it->first - x));
  if (it != koordsYX[y].begin())
    kapcs.push_back(make_pair(prev(it)->second, x - prev(it)->first));
  for (int i = 3; i >= 0; i--) {
    vector<int> minTav(i + 1, (int)2e9 + 1);
    for (pair<int, int> temp : kapcs)
      minTav[table[i][temp.first]] =
          min(minTav[table[i][temp.first]], temp.second);
    int legN = 0;
    for (int z : minTav) legN = max(legN, z);
    ret = min(ret, max(legN, ert[i]));
  }
  return ret;
}
int main() {
  cin.sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  g.resize(n);
  v.resize(n);
  csop.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i].first >> v[i].second;
    koordsXY[v[i].first][v[i].second] = i;
    koordsYX[v[i].second][v[i].first] = i;
  }
  set<int> tavolsag;
  for (int i = 0; i < n; i++) {
    auto it = koordsXY[v[i].first].find(v[i].second);
    if (it != prev(koordsXY[v[i].first].end())) {
      g[i].push_back(make_pair(next(it)->second, next(it)->first - it->first));
      g[next(it)->second].push_back(make_pair(i, next(it)->first - it->first));
      tavolsag.insert(next(it)->first - it->first);
    }
    if (it != koordsXY[v[i].first].begin()) {
      g[i].push_back(make_pair(prev(it)->second, it->first - prev(it)->first));
      g[prev(it)->second].push_back(make_pair(i, it->first - prev(it)->first));
      tavolsag.insert(it->first - prev(it)->first);
    }
    it = koordsYX[v[i].second].find(v[i].first);
    if (it != prev(koordsYX[v[i].second].end())) {
      g[i].push_back(make_pair(next(it)->second, next(it)->first - it->first));
      g[next(it)->second].push_back(make_pair(i, next(it)->first - it->first));
      tavolsag.insert(next(it)->first - it->first);
    }
    if (it != koordsYX[v[i].second].begin()) {
      g[i].push_back(make_pair(prev(it)->second, it->first - prev(it)->first));
      g[prev(it)->second].push_back(make_pair(i, it->first - prev(it)->first));
      tavolsag.insert(it->first - prev(it)->first);
    }
  }
  for (int i = 0; i < 4; i++) ert[i] = (int)2e9 + 1;
  tavolsag.insert(0);
  for (int x : tavolsag) {
    volt.assign(n, false);
    int db = 0;
    for (int i = 0; i < n; i++) {
      if (volt[i]) continue;
      Bejar(i, db, x);
      db++;
    }
    if (db <= 4 && ert[db - 1] == (int)2e9 + 1) {
      ert[db - 1] = x;
      for (int i = 0; i < n; i++) table[db - 1][i] = csop[i];
    }
  }
  int meg = ert[0];
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (v[i].first == v[j].first)
        meg = min(meg, Megold(v[i].first, (v[i].second + v[j].second) / 2));
      else if (v[i].second == v[j].second)
        meg = min(meg, Megold((v[i].first + v[j].first) / 2, v[i].second));
      else {
        meg = min(meg, Megold(v[i].first, v[j].second));
        meg = min(meg, Megold(v[j].first, v[i].second));
      }
    }
  }
  if (meg < (int)2e9 + 1)
    cout << meg << "\n";
  else
    cout << "-1\n";
  return 0;
}
