#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  long long fx[2], fy[2];
  cin >> n >> fx[0] >> fy[0] >> fx[1] >> fy[1];
  long long lx[n], ly[n], d[2][n];
  for (int i = 0; i < n; ++i) {
    cin >> lx[i] >> ly[i];
    for (int j = 0; j < 2; ++j) {
      d[j][i] =
          (lx[i] - fx[j]) * (lx[i] - fx[j]) + (ly[i] - fy[j]) * (ly[i] - fy[j]);
    }
  }
  long long best = 1LL << 60;
  for (int i = -1; i < n; ++i) {
    long long r1;
    if (i == -1)
      r1 = 0;
    else
      r1 = d[0][i];
    long long r2 = 0;
    for (int j = 0; j < n; ++j)
      if (r1 < d[0][j]) r2 = max(r2, d[1][j]);
    best = min(best, r1 + r2);
  }
  cout << best << endl;
}
