#include <bits/stdc++.h>
using namespace std;
struct point {
  long long x, y;
};
long long n, m, s, e, cnt;
bool cmp(pair<long long, long long> a, pair<long long, long long> b) {
  return a.first >= b.first;
}
int main() {
  point fo1, fo2;
  cin >> n >> fo1.x >> fo1.y >> fo2.x >> fo2.y;
  point p[n + 1];
  pair<long long, long long> a[n + 1];
  a[0] = {0, 0};
  for (int i = 1; i <= n; i++) {
    cin >> p[i].x >> p[i].y;
    a[i].first = (long long)(fo1.x - p[i].x) * (fo1.x - p[i].x) +
                 (fo1.y - p[i].y) * (fo1.y - p[i].y);
    a[i].second = (long long)(fo2.x - p[i].x) * (fo2.x - p[i].x) +
                  (fo2.y - p[i].y) * (fo2.y - p[i].y);
  }
  sort(a, a + n + 1, cmp);
  long long mn = 100000000000000000, mx = 0;
  for (int i = 0; i <= n; i++) {
    mn = min(mn, a[i].first + mx);
    mx = max(mx, a[i].second);
  }
  cout << mn;
}
