#include <bits/stdc++.h>
using namespace std;
vector<long long int> fact;
vector<long long int> power;
void fact_init(int n, int mod = 1e9 + 7) {
  int s = 0;
  fact.push_back(1);
  s++;
  for (s = 1; s <= n; s++) {
    fact.push_back((fact[s - 1] * s) % mod);
  }
  return;
}
void pow_init(int n, int base = 2, int mod = 1e9 + 7) {
  int s = 0;
  power.push_back(1);
  s++;
  for (s = 1; s <= n; s++) {
    power.push_back((power[s - 1] * base) % mod);
  }
  return;
}
long long int pow_i(long long int base, int exp, int mod = 1e9 + 7) {
  long long int ans = 1;
  while (exp > 0) {
    if (exp % 2) {
      ans *= base;
      ans %= mod;
    }
    base *= base;
    base %= mod;
    exp /= 2;
  }
  return ans;
}
void swap(int &a, int &b) {
  int temp = a;
  a = b;
  b = temp;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int test;
  test = 1;
  while (test--) {
    int n;
    cin >> n;
    long long int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    vector<pair<long long int, long long int>> v;
    for (int i = 0; i < n; i++) {
      long long int a, b;
      cin >> a >> b;
      long long int d1 = (x1 - a) * (x1 - a) + (y1 - b) * (y1 - b);
      long long int d2 = (x2 - a) * (x2 - a) + (y2 - b) * (y2 - b);
      v.push_back({d1, d2});
    }
    sort(v.begin(), v.end());
    long long int ans = 1e18;
    long long int maxi = 0;
    ans = min(ans, v[n - 1].first);
    for (int i = n - 2; i >= 0; i--) {
      maxi = max(maxi, v[i + 1].second);
      ans = min(ans, maxi + v[i].first);
    }
    ans = min(ans, max(maxi, v[0].second));
    cout << ans << endl;
  }
}
