#include <bits/stdc++.h>
using namespace std;
int n;
pair<int, int> p, q;
pair<int, int> a[2111];
long long ans = 1LL * 1000000000 * 1000000000;
int main() {
  cin >> n;
  cin >> p.first >> p.second >> q.first >> q.second;
  vector<long long> dp(0);
  vector<long long> dq(0);
  for (int i = 0; i < n; ++i) {
    cin >> a[i].first >> a[i].second;
    long long cur = (1LL * a[i].first - p.first) * (a[i].first - p.first) +
                    (1LL * a[i].second - p.second) * (a[i].second - p.second);
    dp.push_back(cur);
    cur = (1LL * a[i].first - q.first) * (a[i].first - q.first) +
          (1LL * a[i].second - q.second) * (a[i].second - q.second);
    dq.push_back(cur);
  }
  ans = *max_element(dq.begin(), dq.end());
  for (int i = 0; i < n; ++i) {
    long long max2 = 0;
    for (int j = 0; j < n; ++j) {
      if (dp[j] > dp[i]) {
        max2 = max(max2, dq[j]);
      }
    }
    ans = min(ans, dp[i] + max2);
  }
  cout << ans << endl;
}
