#include #define REP(i, n) for(int i = 0 ; i < (int)n; ++i) #define X first #define Y second using namespace std; typedef pair ii; int solve(vector pnts, set & allpnts, bool swap){ int mx = 0; sort(pnts.begin(), pnts.end()); /*cerr << endl << endl << "SOLVE" << endl; for(auto && p : pnts){ cerr << p.X << " " << p.Y << endl; }*/ int lstX = -1; vector lst; for(auto && p : pnts){ if(p.X == lstX) lst.push_back(p.Y); else{ REP(i, lst.size())for(int j = i+1; j < (int)lst.size(); ++j) if(lst[j]-lst[i] > mx){ int d = lst[j]-lst[i]; assert(d >= 0); REP(afkjgd, 2){ ii p1, p2; if(!swap){ p1 = {lstX+d, lst[i]}; p2 = {lstX+d, lst[j]}; } else{ p1 = {lst[i], lstX+d}; p2 = {lst[j], lstX+d}; } if(allpnts.find(p1) != allpnts.end() && allpnts.find(p2) != allpnts.end()) mx = abs(d); d*=-1; } } lst.clear(); lstX = p.X; lst.push_back(p.Y); } } return mx; } bool testcase(){ int n; if(!(cin >> n))return false; int sqn = 1; for(;sqn*sqn pnts, pntsX, pntsY; set allpnts; int x, y; REP(i, n){ cin >> x >> y; pnts.push_back({x, y}); allpnts.insert({x, y}); } sort(pnts.begin(), pnts.end()); /* for(auto && p : pnts){ cerr << p.X << " " << p.Y << endl; }*/ int lstX = -1; vector lstY; REP(i, n){ auto p = pnts[i]; if(p.X == lstX) lstY.push_back(p.Y); else{ if((int)lstY.size() <= sqn){ for(auto && y : lstY) pntsX.push_back(ii(lstX, y)); } else{ for(auto && y : lstY) pntsY.push_back(ii(y, lstX)); } lstY.clear(); lstX = p.X; lstY.push_back(p.Y); } } if((int)lstY.size() <= sqn){ for(auto && y : lstY) pntsX.push_back(ii(lstX, y)); } else{ for(auto && y : lstY) pntsY.push_back(ii(y, lstX)); } int ret = max(solve(pntsX, allpnts, false), solve(pntsY, allpnts, true)); cout << ret << endl; return true; } int main(){ while(testcase()); return 0; }