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

#define times(n, i)      uptil(0, n, i)
#define upto(f, t, i)    for(decltype(t) _##i = (t), i = (f); i <= _##i; i++)
#define uptil(f, t, i)   for(decltype(t) _##i = (t), i = (f); i < _##i; i++)
#define downto(f, t, i)  for(decltype(t) _##i = (t), i = (f); i >= _##i; i--)
#define downtil(f, t, i) for(decltype(t) _##i = (t), i = (f); i > _##i; i--)
#define unless(c) if(!(c))
#define until(c) while(!(c))
#define loop while(true)

#define all(v) v.begin(), v.end()
#define ln << "\n"

struct line{};

template<class T> istream& operator>>(istream& in, vector<T>& v) {
    times(v.capacity(), i) in >> v[i];
    return in;
}

template<class T> ostream& operator<<(ostream& out, const vector<T>& v) {
    times(v.size(), i) out << (i ? " " : "") << v[i];
    return out;
}

template<class T, class U> istream& operator>>(istream& in, pair<T, U>& p) {
    T t; U u;
    in >> t >> u;
    p = pair<T, U>(t, u);
    return in;
}

template<class T, class U> ostream& operator<<(ostream& out, const pair<T, U>& p) {
    out << p.first << " " << p.second;
    return out;
}

template<class T, class...U> typename enable_if<is_same<T, line>::value, string>::type next(istream& in, const U&... args) {
    string s;
    getline(in, s, args...);
    return move(s);
}

template<class T, class...U> typename enable_if<!is_same<T, line>::value, T>::type next(istream& in, const U&... args) {
    T t(args...);
    in >> t;
    return move(t);
}
template<class T, class...U> auto next(const U&... args) -> decltype(next<T>(cin)) {
    return next<T>(cin, args...);
}

template<class T> T sum(const vector<T>& v) {
    T ans = T();
    for(const T& t : v) ans += t;
    return ans;
}

template<class T> T sum(const typename vector<T>::iterator& begin, const typename vector<T>::iterator& end) {
    T ans = T();
    for(typename vector<T>::iterator t = begin; t != end; t++) ans += *t;
    return ans;
}

template<class T> T min(const vector<T>& v) {
    return *min_element(v.begin(), v.end());
}

template<class T> T min(const typename vector<T>::iterator& begin, const typename vector<T>::iterator& end) {
    return *min_element(begin, end);
}

template<class T> T min_index(const vector<T>& v) {
    return distance(v.begin(), min_element(v.begin(), v.end()));
}

template<class T> T max(const vector<T>& v) {
    return *max_element(v.begin(), v.end());
}

template<class T> T max(const typename vector<T>::iterator& begin, const typename vector<T>::iterator& end) {
    return *max_element(begin, end);
}

template<class T> T max_index(const vector<T>& v) {
    return distance(v.begin(), max_element(v.begin(), v.end()));
}

template<class T> void sort(vector<T>& v) {
    sort(v.begin(), v.end());
}

const int Broken = 0, Right = 1, Unknown = 2;

bool poll[5005][5005] = {};
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    loop {
        int N = next<int>();
        unless(N) break;
        auto XY = next<vector<pair<int, int>>>(N);
        times(5005, i) times(5005, j) poll[i][j] = false;
        for(auto& p : XY) poll[p.first][p.second] = true;

        int ans = 0;
        times(N, i) {
            times(N, j) {
                int xi = XY[i].first, yi = XY[i].second,
                    xj = XY[j].first, yj = XY[j].second,
                    xd = xi - xj, yd = yi - yj,
                    s = xd * xd + yd * yd;
                if(0 <= xi + yd && xi + yd < 5005 && 0 <= yi - xd && yi - xd < 5005 && poll[xi + yd][yi - xd] &&
                   0 <= xj + yd && xj + yd < 5005 && 0 <= yj - xd && yj - xd < 5005 && poll[xj + yd][yj - xd] ||
                   0 <= xi - yd && xi - yd < 5005 && 0 <= yi + xd && yi + xd < 5005 && poll[xi - yd][yi + xd] &&
                   0 <= xj - yd && xj - yd < 5005 && 0 <= yj + xd && yj + xd < 5005 && poll[xj - yd][yj + xd])
                    ans = max(ans, s);
            }
        }
        cout << ans ln;
    }

    return 0;
}

Measured memory_bytes: 25688