#include <bits/stdc++.h>
using namespace std;
const int sz = 78489;
bool isp[1000000];
vector<int> pl;
map<int, int> cnt;
int dat[500005];
int main() {
  isp[2] = true;
  for (int i = 3; i < 1000000; i += 2) isp[i] = true;
  for (int i = 3; i * i < 1000000; i += 2) {
    if (!isp[i]) continue;
    for (int j = i * i; j < 1000000; j += i) isp[j] = false;
  }
  pl.push_back(2);
  for (int i = 3; i < 1000000; i += 2)
    if (isp[i]) pl.push_back(i);
  int n, x, y, c1 = 0, odd = 0;
  scanf("%d%d%d", &n, &x, &y);
  for (int i = 0; i < n; i++) {
    scanf("%d", dat + i);
    int z = dat[i];
    if (z == 1) c1++;
    if (z & 1) odd++;
    for (int j : pl) {
      if (j > 1000) {
        if (z > 1) cnt[z]++;
        break;
      }
      if (z % j) continue;
      cnt[j]++;
      while (z % j == 0) z /= j;
    }
  }
  if (c1 == n) {
    printf("%lld\n", 1LL * min(x, y) * n);
    return 0;
  }
  long long z = min(x, y);
  long long ans = min(1LL * (n - 1) * x, 1LL * odd * y);
  for (int p : pl) {
    if (cnt[p] == n) {
      puts("0");
      return 0;
    }
    if (z * (n - cnt[p]) >= ans || n - cnt[p] >= odd) continue;
    long long tmp = 0, nemin = 1e18;
    bool eall = true;
    for (int j = 0; j < n; j++) {
      if (dat[j] % p == 0) {
        eall = false;
        continue;
      }
      long long a = x, b = 1LL * (p - dat[j] % p) * y;
      if (a < b) {
        tmp += a;
        nemin = min(nemin, b - a);
      } else {
        tmp += b;
        eall = false;
      }
      if (tmp >= ans) break;
    }
    if (eall) tmp += nemin;
    if (tmp < ans) ans = tmp;
  }
  printf("%lld\n", ans);
}
