#include typedef long long ll; typedef long double ld; using namespace std; #define rep(i, a, n) for (int i = (a); i < (n); i++) #define per(i, a, n) for (int i = (n) - 1; i >= (a); i--) #define x first #define y second const int MAGIC = 350; ll pairhash(int x, int y) { return (((ll)x)<<32) | ((ll)y); } int main(void) { ios::sync_with_stdio(false); int n; while(cin>>n) { vector> a; unordered_map> diag; unordered_set pts; rep(i,0,n) { int x, y; cin >> x >> y; a.push_back({x,y}); diag[x-y].push_back(i); pts.insert(pairhash(x, y)); } int best = 0; for (auto& pd : diag) { auto &delta = pd.first; auto &d = pd.second; if(d.size() < MAGIC) { rep(i,0,d.size()) { rep(j,i+1,d.size()) { int val = abs(a[d[i]].x - a[d[j]].x); if( val > best && pts.count(pairhash(a[d[i]].x, a[d[j]].y)) && pts.count(pairhash(a[d[j]].x, a[d[i]].y))) { best = max(best, val); } } } } else { for(auto &p : a) { int cd = delta - (p.x - p.y); if(cd < best) continue; if (pts.count(pairhash(p.x + cd, p.y)) && pts.count(pairhash(p.x, p.y - cd)) && pts.count(pairhash(p.x + cd, p.y - cd))) { best = max(best, cd); } } } } cout << best << endl; } return 0; }