#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1e9 + 10;
const int MAXN = (int)2e3 + 10;
long long x[MAXN], y[MAXN], r1, r2, ans;
int n;
bool used[MAXN];
int main() {
  ans = 1LL * inf * inf;
  cin >> n;
  for (int i = 0; i < n + 2; ++i) cin >> x[i] >> y[i];
  for (int i = 0; i < n + 2; ++i) {
    for (int j = 0; j < n + 2; ++j) used[j] = false;
    r1 = (x[0] - x[i]) * (x[0] - x[i]) + (y[0] - y[i]) * (y[0] - y[i]);
    for (int j = 0; j < n + 2; ++j) {
      long long d =
          (x[0] - x[j]) * (x[0] - x[j]) + (y[0] - y[j]) * (y[0] - y[j]);
      if (d <= r1) used[j] = true;
    }
    r2 = 0LL;
    for (int j = 0; j < n + 2; ++j) {
      if (used[j]) continue;
      long long d =
          (x[1] - x[j]) * (x[1] - x[j]) + (y[1] - y[j]) * (y[1] - y[j]);
      r2 = max(r2, d);
    }
    ans = min(ans, r2 + r1);
  }
  cout << ans << endl;
  return 0;
}
