#include <bits/stdc++.h>
using namespace std;
long long dsq(int x1, int y1, int x2, int y2) {
  return (long long)(x1 - x2) * (x1 - x2) + (long long)(y1 - y2) * (y1 - y2);
}
int main() {
  int n, x1, y1, x2, y2;
  scanf("%d%d%d%d%d", &n, &x1, &y1, &x2, &y2);
  vector<pair<long long, long long>> d(n);
  for (int i = 0; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    d[i] = {dsq(x, y, x1, y1), dsq(x, y, x2, y2)};
  }
  sort((d).begin(), (d).end());
  vector<long long> ms(n);
  ms[n - 1] = d[n - 1].second;
  for (int i = n - 2; i >= 0; i--) ms[i] = max(ms[i + 1], d[i].second);
  long long best = ms[0];
  for (int i = 1; i < n; i++) best = min(best, d[i - 1].first + ms[i]);
  best = min(best, d[n - 1].first);
  printf("%lld\n", best);
}
