#include <bits/stdc++.h>
using namespace std;
long long x[2005], y[2005], suffix[2005];
vector<pair<long long, long long> > V;
long long dist(long long x1, long long y1, long long x2, long long y2) {
  long long tot = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
  return tot;
}
int main() {
  long long n, x1, y1, x2, y2, ans = LLONG_MAX;
  cin >> n >> x1 >> y1 >> x2 >> y2;
  for (int i = 1; i <= n; i++) {
    cin >> x[i] >> y[i];
    long long a = dist(x[i], y[i], x1, y1), b = dist(x[i], y[i], x2, y2);
    V.push_back({a, b});
  }
  sort(V.begin(), V.end());
  for (int i = n - 1; i >= 0; i--) suffix[i] = max(suffix[i + 1], V[i].second);
  ans = suffix[0];
  for (int i = 0; i < n; i++) {
    ans = min(ans, V[i].first + suffix[i + 1]);
  }
  cout << ans;
}
