#include <bits/stdc++.h>
using namespace std;

using lint = long long;
#define reps(i, a, n) for (lint i = (a); i < (lint)(n); ++i)
#define rep(i, n) reps(i, 0, n)
struct pre_{pre_(){cin.tie(0);ios::sync_with_stdio(0);}} pre__;

struct P {
  int x, y;
};

inline bool inside(int x, int y, int w, int h) {
  return 0 <= x && x < w && 0 <= y && y < h;
}

bool field[5010][5010];

signed main() {
  int n;

  while (cin >> n, n) {
    vector<P> p(n);
    memset(field, false, sizeof(field));
    rep(i, n) {
      cin >> p[i].x >> p[i].y;
      field[p[i].x][p[i].y] = true;
    }
    int res = 0;
    rep(i, n) rep(j, n) {
      if (i == j) continue;
      P d = (P){abs(p[i].x - p[j].x), abs(p[i].y - p[j].y)};
      P next1 = (P){p[i].x + d.y, p[i].y - d.x},
        next2 = (P){p[j].x + d.y, p[j].y - d.x};
      if (!inside(next1.x, next1.y, 5001, 5001)) continue;
      if (!inside(next2.x, next2.y, 5001, 5001)) continue;
      if (field[next1.x][next1.y] && field[next2.x][next2.y]) {
        res = max(res, d.x * d.x + d.y * d.y);
      }
    }
    cout << res << '\n';
  }
}