#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
bool data[5001][5001];
bool isOK(int x,int y){
  return x >= 0 && x < 5001 && y >= 0 && y < 5001 && data[x][y];
}
int main(){
  int n;
  int x[3000], y[3000];
  while(scanf("%d", &n) , n){
    memset( data,false,sizeof(data));
    for(int i = 0 ; i < n ; i++ ){
      scanf("%d %d",&x[i],&y[i]);
      data[x[i]][y[i]] = true;
    }
    int ret = 0;
    for(int i = 0 ; i < n ; i++ ){
      for(int j = 0 ; j < i ; j++ ){
        int xx = x[j] - x[i];
        int yy = y[j] - y[i];
        if(isOK(x[i] + yy,y[i] - xx) & isOK(x[j] + yy,y[j] - xx))
          ret = max( ret, xx * xx + yy * yy);
      }
    }
    printf("%d\n",ret);
  }
}