#include <cstdio>

using namespace std;
bool ch[5001][5001];
int main(){
  
  while(1){
  
  int n,d[3002][2] = {0},ans = 0;
  
  
  scanf("%d",&n);
  
  if(n == 0)break;
  
  for(int i = 0;i < n;i++){
    scanf("%d%d",&d[i][0],&d[i][1]);
    ch[d[i][0]][d[i][1]] = true;
  }
  
  
  for(int i = 0;i < n;i++){
    for(int j = i + 1;j < n;j++){
      int x1 = d[i][0]; int y1 = d[i][1];
      int x2 = d[j][0]; int y2 = d[j][1];
      int po = (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2);
      if(po <= ans) continue;
      int x3 = x2 + y2 - y1;
      int y3 = y2 + x1 - x2;
      if(x3 < 0 || x3 > 5000 || y3 < 0 || y3 > 5000 || ch[x3][y3] == false)continue;
      int x4 = x1 + y2 - y1;
      int y4 = y1 + x1 - x2;
      if(x4 >= 0 && x4 <= 5000 && y4 >= 0 && y4 <= 5000 & ch[x4][y4]){
	ans = po;
      }
    }
  }
  
  printf("%d\n",ans);
  }
      

  return 0;
}
    
    
