#include <bits/stdc++.h>   using namespace std;   long long t[2003];   long long viz[2003];   pair<long long, long long> a[2003];   pair<pair<long long, long long>, long long> b[2003];   vector<long long> v[2003];   vector<pair<pair<long long, long long>, long long> > much;   vector<pair<pair<long long, long long>, long long> > muchsel;   bool cmp_first(pair<pair<long long, long long>, long long> a,                  pair<pair<long long, long long>, long long> b) {     if (a.first.first == b.first.first) return a.first.second < b.first.second;     return a.first.first < b.first.first;   }   bool cmp_second(pair<pair<long long, long long>, long long> a,                   pair<pair<long long, long long>, long long> b) {     if (a.first.second == b.first.second) return a.first.first < b.first.first;     return a.first.second < b.first.second;   }   bool cmp(pair<pair<long long, long long>, long long> a,            pair<pair<long long, long long>, long long> b) {     return a.second < b.second;   }   long long dist(pair<long long, long long> a, pair<long long, long long> b) {     return abs(a.first - b.first) + abs(a.second - b.second);   }   long long root(long long x) {     if (t[x] == 0) return x;     t[x] = root(t[x]);     return t[x];   }   void calc(long long mx) {     muchsel.clear();     long long rx, ry;     int id = 0;     for (auto val : much) {       rx = root(val.first.first);       ry = root(val.first.second);       if (val.second > mx) return;       if (rx != ry) {         t[rx] = ry;         viz[id] = 1;         muchsel.push_back(val);       }       id++;     }     return;   }   long long intercl(pair<long long, long long> a, pair<long long, long long> b,                     pair<long long, long long> c, pair<long long, long long> d) {     long long x = -1, y = -1;     if (a.first == b.first) x = a.first;     if (a.second == b.second) y = a.second;     if (c.first == d.first) x = c.first;     if (c.second == d.second) y = c.second;     if (x != -1 && y != -1) {       long long val1 = max(abs(x - a.first), abs(x - b.first)),                 val2 = max(abs(y - a.second), abs(y - b.second)),                 val3 = max(abs(x - c.first), abs(x - d.first)),                 val4 = max(abs(y - c.second), abs(y - d.second));       long long val = max(val1, max(val2, max(val3, val4)));       return val;     }     return 2000000000000000018;   }   void cleart(long long n) {     for (int i = 1; i <= n; ++i) t[i] = 0;   }   bool solve(long long n, long long t) {     cleart(n);     calc(t);     long long sz = muchsel.size();     long long nrc = n - sz;     long long rx, ry, rk, rq;     if (nrc == 1) return true;     if (nrc == 2) {       for (int i = 1; i <= n; ++i) {         rx = root(i);         for (int j = i + 1; j <= n; ++j) {           ry = root(j);           if (rx == ry) continue;           long long ds =               max(abs(a[i].first - a[j].first), abs(a[i].second - a[j].second));           if (ds <= t) return true;           if (a[i].first == a[j].first || a[i].second == a[j].second)             if ((ds + 1) / 2 <= t) return true;         }       }       return false;     }     if (nrc == 3) {       for (int i = 0; i < much.size(); ++i) {         rx = root(much[i].first.first);         ry = root(much[i].first.second);         if (rx == ry) continue;         for (int j = 1; j <= n; ++j) {           rk = root(j);           if (rx == rk || ry == rk) continue;           pair<long long, long long> e1 = a[much[i].first.first];           pair<long long, long long> e2 = a[much[i].first.second];           pair<long long, long long> e3 = a[j];           pair<long long, long long> pct = {-2000000000000000018,                                             -2000000000000000018};           if (e1.first == e2.first) pct = {e1.first, e3.second};           if (e1.first == e3.first) pct = {e1.first, e2.second};           if (e2.first == e3.first) pct = {e2.first, e1.second};           if (e1.second == e2.second) pct = {e3.first, e1.second};           if (e1.second == e3.second) pct = {e2.first, e1.second};           if (e2.second == e3.second) pct = {e1.first, e2.second};           if (max(dist(e1, pct), max(dist(e2, pct), dist(e3, pct))) <= t)             return true;         }       }       return false;     }     if (nrc == 4) {       for (int i = 0; i < much.size(); ++i) {         rx = root(much[i].first.first);         ry = root(much[i].first.second);         if (rx == ry) continue;         for (int j = i + 1; j < much.size(); ++j) {           rk = root(much[j].first.first);           rq = root(much[j].first.second);           if (rk == rq || rx == rk || rx == rq || ry == rk || ry == rq) continue;           if (intercl(a[much[i].first.first], a[much[i].first.second],                       a[much[j].first.first], a[much[j].first.second]) <= t)             return true;         }       }       return false;     }     return false;   }   int main() {     long long n;     cin >> n;     for (int i = 1; i <= n; ++i) {       cin >> a[i].first >> a[i].second;       b[i] = {a[i], i};     }     sort(b + 1, b + n + 1, cmp_first);     for (int i = 1; i < n; ++i) {       if (b[i].first.first == b[i + 1].first.first) {         long long dif = b[i + 1].first.second - b[i].first.second,                   id1 = b[i].second, id2 = b[i + 1].second;         if (dif < 0) dif = -dif;         v[id1].push_back(id2);         v[id2].push_back(id1);         much.push_back({{id1, id2}, dif});       }     }     sort(b + 1, b + n + 1, cmp_second);     for (int i = 1; i < n; ++i) {       if (b[i].first.second == b[i + 1].first.second) {         long long dif = b[i + 1].first.first - b[i].first.first,                   id1 = b[i].second, id2 = b[i + 1].second;         if (dif < 0) dif = -dif;         v[id1].push_back(id2);         v[id2].push_back(id1);         much.push_back({{id1, id2}, dif});       }     }     sort(much.begin(), much.end(), cmp);     long long st = 1, dr = 2000000009;     while (st <= dr) {       long long mij = (st + dr) / 2;       if (solve(n, mij))         dr = mij - 1;       else         st = mij + 1;     }     if (solve(n, dr))       cout << dr <<   n ;     else {       if (st == 2000000009 + 1)         cout << -1 <<   n ;       else         cout << st <<   n ;     }     return 0;   }