#include <bits/stdc++.h>
using namespace std;
long long int n, x1, x2, yp, y2, x, y, mx = 0, res;
vector<pair<long long int, long long int> > v;
int main() {
  cin >> n >> x1 >> yp >> x2 >> y2;
  for (int i = 0; i < n; i++) {
    cin >> x >> y;
    v.push_back(
        make_pair((x - x1) * 1ll * (x - x1) + (y - yp) * 1ll * (y - yp),
                  (x - x2) * 1ll * (x - x2) + (y - y2) * 1ll * (y - y2)));
    if (mx < v[i].second) mx = v[i].second;
  }
  if (n == 1) {
    cout << min(v[0].first, v[0].second);
    return 0;
  }
  sort(v.begin(), v.end());
  res = mx;
  res = min(res, v[n - 1].first);
  for (int i = n - 2; i >= 0; i--) {
    swap(v[i + 1].first, v[i + 1].second);
    sort(v.begin() + i + 1, v.end());
    res = min(res, v[i].first + v[n - 1].first);
  }
  cout << res << endl;
  return 0;
}
