#include <vector>
#include <iostream>
#include <algorithm>
#pragma warning(disable : 4996)
using namespace std;
int n, x[3009], y[3009]; bool ok[5009][5009];
int main() {
	while (scanf("%d", &n), n) {
		for (int i = 0; i < n; i++) {
			scanf("%d%d", &x[i], &y[i]);
			ok[x[i]][y[i]] = true;
		}
		int ret = 0;
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				int va = x[j] - x[i], vb = y[j] - y[i];
				int ex = x[i] + vb, ey = y[i] - va;
				int fx = x[j] + vb, fy = y[j] - va;
				if (0 <= ex && ex <= 5000 && 0 <= ey && ey <= 5000 && 0 <= fx && fx <= 5000 && 0 <= fy && fy <= 5000 && ok[ex][ey] && ok[fx][fy]) {
					ret = max(ret, va * va + vb * vb);
				}
			}
		}
		printf("%d\n", ret);
		for (int i = 0; i < n; i++) ok[x[i]][y[i]] = false;
	}
	return 0;
}