#include <bits/stdc++.h>
using namespace std;
template <typename A, typename B>
ostream &operator<<(ostream &os, const pair<A, B> &p);
template <typename A>
ostream &operator<<(ostream &os, const set<A> &m) {
  os << "{";
  string sep = "";
  for (auto e : m) os << sep << e, sep = ", ";
  return os << "}";
}
template <typename A>
ostream &operator<<(ostream &os, const multiset<A> &m) {
  os << "{";
  string sep = "";
  for (auto e : m) os << sep << e, sep = ", ";
  return os << "}";
}
template <typename A, typename B>
ostream &operator<<(ostream &os, const map<A, B> &m) {
  os << "{";
  string sep = "";
  for (auto e : m) os << sep << e.first << ": " << e.second, sep = ", ";
  return os << "}";
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "[";
  string sep = "";
  for (auto e : v) os << sep << e, sep = ", ";
  return os << "]";
}
template <typename A, typename B>
ostream &operator<<(ostream &os, const pair<A, B> &p) {
  os << '(' << p.first << ", " << p.second << ')';
  return os;
}
void dbg_out() { cerr << endl; }
template <typename Head, typename... Tail>
void dbg_out(Head H, Tail... T) {
  cerr << ' ' << H;
  dbg_out(T...);
}
const int inf = 2000 << 20;
int main() {
  int n;
  cin >> n;
  vector<int> vx(n), vy(n);
  vector<pair<int, int>> pts(n);
  auto dist = [&](pair<int, int> a, pair<int, int> b) -> int {
    if (a.first == b.first) return abs(a.second - b.second);
    if (a.second == b.second) return abs(a.first - b.first);
    return inf;
  };
  map<pair<int, int>, int> xy, yx;
  xy[pair<int, int>(-inf, -inf)] = xy[pair<int, int>(inf, inf)] = -1;
  yx[pair<int, int>(-inf, -inf)] = yx[pair<int, int>(inf, inf)] = -1;
  for (int i = 0; i < n; ++i) {
    cin >> vx[i] >> vy[i];
    pts[i] = pair<int, int>(vx[i], vy[i]);
    xy[pair<int, int>(vx[i], vy[i])] = i;
    yx[pair<int, int>(vy[i], vx[i])] = i;
  }
  set<int> xs(vx.begin(), vx.end()), ys(vy.begin(), vy.end());
  ;
  vector<pair<int, int>> tocheck;
  for (int x : xs) {
    for (int y : ys) {
      tocheck.push_back(pair<int, int>(x, y));
    }
  }
  pair<int, int> prv = xy.begin()->first;
  for (auto pp : xy) {
    pair<int, int> p = pp.first;
    if (prv != p && prv.first == p.first) {
      tocheck.push_back(pair<int, int>(p.first, (prv.second + p.second) / 2));
    }
    prv = p;
  }
  prv = yx.begin()->first;
  for (auto pp : yx) {
    pair<int, int> p = pp.first;
    if (prv != p && prv.first == p.first) {
      tocheck.push_back(pair<int, int>((prv.second + p.second) / 2, p.first));
    }
    prv = p;
  };
  vector<vector<pair<int, int>>> cands;
  for (pair<int, int> p : tocheck) {
    vector<pair<int, int>> neighbors;
    auto it = xy.lower_bound(p);
    int a = it->second, b = (--it)->second;
    it = yx.lower_bound(pair<int, int>(p.second, p.first));
    int c = it->second, d = (--it)->second;
    vector<int> v({a, b, c, d});
    for (int i : v) {
      if (i == -1) continue;
      int d = dist(p, pts[i]);
      if (d < inf) {
        neighbors.push_back(pair<int, int>(d, i));
      }
    }
    sort(neighbors.begin(), neighbors.end());
    cands.push_back(neighbors);
  };
  vector<pair<int, pair<int, int>>> edges;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      int d = dist(pts[i], pts[j]);
      if (d >= inf) continue;
      edges.emplace_back(d, pair<int, int>(i, j));
    }
  }
  sort(edges.begin(), edges.end());
  ;
  vector<int> group(n);
  for (int i = 0; i < n; ++i) group[i] = i;
  int numGroups = n;
  int ans = inf;
  int t = 0;
  auto check = [&]() -> int {
    if (numGroups > 4) return inf;
    if (numGroups == 1) return t;
    ;
    int ret = inf;
    for (auto &v : cands) {
      set<int> s;
      for (auto &p : v) {
        s.insert(group[p.second]);
        if (int((s).size()) >= numGroups) {
          ;
          ret = min(ret, max(t, p.first));
        }
      }
    }
    return ret;
  };
  ans = min(ans, check());
  for (auto p : edges) {
    int a = p.second.first, b = p.second.second;
    if (group[a] == group[b]) continue;
    int ga = group[a];
    for (int &i : group)
      if (i == ga) i = group[b];
    --numGroups;
    t = p.first;
    ans = min(ans, check());
  }
  if (ans == inf) ans = -1;
  cout << ans << "\n";
}
