#include <bits/stdc++.h>
using namespace std;
const int MAXN = 500005, mod = 1e9 + 7;
vector<int> prim;
bool nah[1000005];
int ilu[1000005], t[MAXN];
int main() {
  int a, b, c, d, e, n, k, m, del, inc;
  long long w, s;
  for (a = 2; a <= 100; a++)
    if (!nah[a])
      for (b = a * a; b <= 1000; b += a) nah[b] = 1;
  for (a = 2; a <= 1000; a++)
    if (!nah[a]) prim.push_back(a);
  scanf("%d%d%d", &n, &del, &inc);
  for (a = 0; a < n; a++) {
    scanf("%d", &t[a]);
    b = t[a];
    for (auto x : prim) {
      if (b % x == 0) ilu[x]++;
      for (; b % x == 0; b /= x)
        ;
    }
    if (b > 1) ilu[b]++;
  }
  b = 0;
  for (a = 0; a <= 1000000; a++) b = max(b, ilu[a]);
  w = (long long)(n - b) * del;
  for (a = 0; a < n; a++) {
    b = t[a] + 1;
    for (auto x : prim) {
      if (b % x == 0) ilu[x]++;
      for (; b % x == 0; b /= x)
        ;
    }
    if (b > 1) ilu[b]++;
  }
  for (a = 2; a <= 1000000; a++)
    if (ilu[a] >= n / 2) {
      s = 0;
      for (b = 0; b < n; b++)
        s += min((long long)del,
                 (long long)inc * ((t[b] + a - 1) / a * a - t[b]));
      w = min(w, s);
    }
  printf("%lld", w);
  return 0;
}
