#include <bits/stdc++.h>
using namespace std;
typedef struct P {
  long long x, y;
  int s1, s2;
} P;
int N;
vector<P*> vs1, vs2;
P P1, P2;
long long dispow(P* a, P* b) {
  return (a->x - b->x) * (a->x - b->x) + (a->y - b->y) * (a->y - b->y);
}
bool cmp1(P* a, P* b) { return dispow(a, &P1) < dispow(b, &P1); }
bool cmp2(P* a, P* b) { return dispow(a, &P2) < dispow(b, &P2); }
int main() {
  cin >> N;
  scanf("%I64d %I64d %I64d %I64d", &P1.x, &P1.y, &P2.x, &P2.y);
  vector<P*> vs1;
  for (int i = 0; i < N; i++) {
    vs1.push_back(new P());
    scanf("%I64d %I64d", &vs1[i]->x, &vs1[i]->y);
  }
  vector<P*> vs2(vs1);
  sort(vs1.begin(), vs1.end(), cmp1);
  sort(vs2.begin(), vs2.end(), cmp2);
  for (int i = 0; i < N; i++) vs1[i]->s1 = vs2[i]->s2 = i;
  long long res = dispow(vs2[N - 1], &P2);
  for (int i = 0; i < N; i++) {
    P* a = vs1[i];
    int ms2 = -1;
    for (int j = i + 1; j < N; j++) ms2 = max(ms2, vs1[j]->s2);
    if (ms2 != -1) {
      P* b = vs2[ms2];
      res = min(res, dispow(a, &P1) + dispow(b, &P2));
    } else
      res = min(res, dispow(a, &P1));
  }
  cout << res;
  return 0;
}
