#include <bits/stdc++.h>
using namespace std;
int n;
long long x1, sfdgj, x2, y2;
struct point {
  long long x, y;
} p[2009];
long long sqr(long long a) { return a * a; }
bool comp1(point a, point b) {
  return sqr(a.x - x1) + sqr(a.y - sfdgj) < sqr(b.x - x1) + sqr(b.y - sfdgj);
}
int main() {
  scanf("%d", &n);
  scanf("%I64d %I64d %I64d %I64d", &x1, &sfdgj, &x2, &y2);
  for (int i = 0; i < n; i++) {
    scanf("%I64d %I64d", &p[i].x, &p[i].y);
  }
  sort(p, p + n, comp1);
  long long ans = 1000000000000000000LL;
  for (int i = 0; i <= n; i++) {
    long long a = 0, b = 0;
    for (int j = i; j < n; j++) {
      a = max(a, (p[j].x - x2) * (p[j].x - x2) + (p[j].y - y2) * (p[j].y - y2));
    }
    for (int j = 0; j < i; j++) {
      b = max(b, (p[j].x - x1) * (p[j].x - x1) +
                     (p[j].y - sfdgj) * (p[j].y - sfdgj));
    }
    ans = min(ans, a + b);
  }
  printf("%I64d", ans);
}
