#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 100000005
#define MAX 5002
using namespace std;

pair<int, int> p[3004];
bool a[MAX][MAX];

bool s(int n){
	if(0 <= n && n <= 5000)return 1;
	return 0;
}

int main(){
	int n, t1, t2;
	while(cin >> n, n){
		fill((int*)a, (int*)(a+MAX), 0);
		for(int i = 0;i < n;i++){
			cin >> t1 >> t2;
			p[i].first = t1;
			p[i].second = t2;
			a[t2][t1] = 1;
		}
		
		int ans = 0;
		int p1[4][2], f1, f2;
		for(int i = 0;i < n;i++){
			for(int j = 0;j < n;j++){
				f1 = f2 = 0;
				t1 = p[i].first-p[j].first;
				t2 = p[i].second-p[j].second;
				if(!t1 && !t2)continue;
				int x1=p[i].first-t2,y1=p[i].second+t1,x2=p[j].first-t2,y2=p[j].second+t1;
				int x3=p[i].first-t2,y3=p[i].second+t1,x4=p[j].first+t2,y4=p[j].second-t1;
				if(s(x1)&&s(y1)&&a[y1][x1]&&s(x2)&&s(y2)&&a[y2][x2])
				ans = max(ans, t1*t1+t2*t2);
				if(s(y3)&&s(x3)&&a[y3][x3]&&s(y4)&&s(x4)&&a[y4][x4])
				ans = max(ans, t1*t1+t2*t2);
			}
		}
		//cout << endl;
		//for(int i = 0;i < 4;i++)cout << (i>>1&1) << " " << (i&1) << endl;
		cout << ans << endl;
	}
	return 0;
}