#include <bits/stdc++.h>
using namespace std;
inline long long sqr(int a) { return a * (long long)a; }
struct compare {
  bool operator()(const pair<long long, long long> &left,
                  const pair<long long, long long> &right) {
    return left.first < right.first;
  }
};
long long ans = LONG_LONG_MAX;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  vector<pair<long long, long long> > dist;
  long long n, x1, y1, x2, y2;
  int x, y;
  cin >> n >> x1 >> y1 >> x2 >> y2;
  long long *maxi = new long long[n + 2];
  maxi[n] = 0;
  for (int i = 0; i < n; i++) {
    cin >> x >> y;
    dist.push_back(
        make_pair(sqr(x - x1) + sqr(y - y1), sqr(x - x2) + sqr(y - y2)));
  }
  sort(dist.begin(), dist.end(), compare());
  for (int i = n - 1; i >= 0; i--) {
    maxi[i] = max(dist[i].second, maxi[i + 1]);
  }
  ans = maxi[0];
  for (int i = 0; i < n; i++) {
    ans = min(ans, dist[i].first + maxi[i + 1]);
  }
  cout << ans;
}
