#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
int N, x, y;
pair<int, int> a[500010];
int pdp[1010];
bool used[1000010];
vector<int> primes;
void sieve() {
  for (int i = 2; i <= 1000; i++) {
    if (pdp[i]) continue;
    primes.push_back(i);
    for (int j = 2 * i; j <= 1000; j += i) {
      pdp[j] = 1;
    }
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  sieve();
  cin >> N >> x >> y;
  for (int i = 0; i < N; i++) {
    cin >> a[i].second;
    int big = a[i].second;
    for (int p : primes) {
      while (big % p == 0) big /= p;
      if (big == 1) break;
    }
    if (big > 1) a[i].first = big;
  }
  long long best = 1e18;
  int bestmod = 1e9;
  for (int p : primes) {
    long long curr = 0;
    int curmod = 0;
    for (int i = 0; i < N; i++) {
      long long cost =
          min(1ll * x, 1ll * y * (p - ((a[i].second + p - 1) % p + 1)));
      curr += cost;
      if (cost > 0) curmod++;
      if (curr > best) break;
    }
    if (best >= curr) {
      best = curr;
      bestmod = min(bestmod, curmod);
    }
  }
  sort(a, a + N, greater<pair<int, int> >());
  for (int i = 0; i < N; i++) {
    int n = a[i].second, p = a[i].first;
    if (p == 0) break;
    if (used[p]) continue;
    used[p] = 1;
    int j = i;
    while (j < N && a[j].first == p) j++;
    if (1ll * (N - (j - i)) * min(x, y) >= best) continue;
    long long curr = 0;
    for (int k = 0; k < N; k++) {
      long long cost =
          min(1ll * x, 1ll * y * (p - ((a[k].second + p - 1) % p + 1)));
      curr += cost;
      if (curr > best) break;
    }
    if (best > curr) best = curr;
  }
  cout << best << '\n';
  return 0;
}
