#include <bits/stdc++.h>
using namespace std;
long long int fx[4], fy[4], x[2005], y[2005];
long long int minimum(long long int a, long long int b) {
  if (a < b) return a;
  return b;
}
long long int maximum(long long int a, long long int b) {
  if (a > b) return a;
  return b;
}
int main() {
  long long int i, j, b, c, n, m, ans = 1, mn1, mn2, mx1, mx2, ret, mn, dis1,
                                  dis2;
  mx1 = mx2 = -1;
  mn1 = mn2 = mn = 100000000000000000;
  scanf("%lld", &n);
  scanf("%lld %lld %lld %lld", &fx[1], &fy[1], &fx[2], &fy[2]);
  for (i = 1; i <= n; i++) {
    scanf("%lld %lld", &x[i], &y[i]);
  }
  x[0] = fx[1];
  y[0] = fy[1];
  for (i = 0; i <= n; i++) {
    dis1 =
        ((fx[1] - x[i]) * (fx[1] - x[i])) + ((fy[1] - y[i]) * (fy[1] - y[i]));
    mx2 = 0;
    for (j = 1; j <= n; j++) {
      ret =
          ((fx[1] - x[j]) * (fx[1] - x[j])) + ((fy[1] - y[j]) * (fy[1] - y[j]));
      if (ret > dis1 || i < 1) {
        dis2 = ((fx[2] - x[j]) * (fx[2] - x[j])) +
               ((fy[2] - y[j]) * (fy[2] - y[j]));
        mx2 = maximum(dis2, mx2);
      }
    }
    mn = minimum(mn, (dis1 + mx2));
  }
  printf("%lld\n", mn);
  return 0;
}
