#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2005;
const int64_t INF = 1LL << 60;
int n;
int64_t r = INF, cost;
pair<int, int> f1, f2, a[MAXN];
inline int64_t sq(int64_t x) { return x * x; }
inline int64_t distance(const pair<int, int> &x, const pair<int, int> &y) {
  return sq(1LL * x.first - y.first) + sq(1LL * x.second - y.second);
}
int main() {
  cin >> n >> f1.first >> f1.second >> f2.first >> f2.second;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i].first >> a[i].second;
  }
  sort(a + 1, a + 1 + n, [&](const pair<int, int> &x, const pair<int, int> &y) {
    return (distance(x, f1) < distance(y, f1));
  });
  for (int i = n; i >= 0; --i) {
    r = min(r, distance(f1, a[i]) * !!(i) + cost);
    cost = max(cost, distance(f2, a[i]));
  }
  cout << r << '\n';
}
