#include <bits/stdc++.h>
using namespace std;
long long int x, y;
long long int gcd(long long int a, long long int b) {
  if (a == 0) {
    x = 0, y = 1;
    return b;
  }
  long long int gc = gcd(b % a, a);
  long long int temp;
  temp = x;
  x = y - (b / a) * temp;
  y = temp;
  return gc;
}
long long int pow(long long int a, long long int x, long long int m) {
  long long int ans = 1, k = 1;
  while (k <= x) {
    if (x % k) ans = ((ans * a) % m);
    k <<= 1;
    a *= a;
    a %= m;
  }
  return ans;
}
vector<int> fac[1000005];
int second[1000005];
void sieve() {
  int i, j;
  for (i = 2; i < 1000005; i += 2) fac[i].push_back(2);
  for (i = 3; i < 1000005; i += 2) {
    if (second[i] != -1) {
      for (j = 1; i * j < 1000005; j++) {
        fac[i * j].push_back(i);
      }
    }
  }
}
int coun[1000005];
int a[1000005];
vector<pair<int, int> > t;
int n;
long long int inline check(long long int val) {
  long long int ans = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] % val != 0) {
      ans += min(x, y * (val - a[i] % val));
    }
  }
  return ans;
}
bool compare(pair<int, int> lhs, pair<int, int> rhs) {
  return lhs.first > rhs.first;
}
int main() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  cin.tie(0);
  sieve();
  cin >> n >> x >> y;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    for (auto j : fac[a[i]]) {
      coun[j]++;
    }
  }
  long long int ans = check(2);
  for (int i = 3; i < 1000005; i++) {
    if (coun[i] > 0) {
      t.push_back({coun[i], i});
    }
  }
  sort(t.begin(), t.end(), compare);
  for (int i = 0; i < 100 && i < t.size(); i++) {
    ans = min(ans, check(t[i].second));
  }
  cout << ans << "\n";
}
