#include <bits/stdc++.h>
using namespace std;
const int N = 500010;
const int Ai = 1000010;
int prime[Ai / 10], min_factor[Ai];
int a[N];
long long s[N];
int n, pt = 0, ma, max_add;
long long x, y, ans = 1ll << 62;
void Euler(int n) {
  for (int i = 2; i <= n; ++i) {
    if (min_factor[i] == 0) min_factor[i] = prime[++pt] = i;
    int k;
    for (int j = 1; j <= pt && (k = prime[j] * i) <= n; j++)
      min_factor[k] = prime[j];
  }
}
int find_lt(int num, int l = 1, int r = n) {
  while (l < r) {
    int mid = (l + r + 1) >> 1;
    if (a[mid] <= num)
      l = mid;
    else
      r = mid - 1;
  }
  return l;
}
int find_gt(int num, int l = 1, int r = n) {
  while (l < r) {
    int mid = (l + r) >> 1;
    if (a[mid] >= num)
      r = mid;
    else
      l = mid + 1;
  }
  return l;
}
long long work(int p) {
  int val, now = 1;
  long long sum = 0;
  a[n] = a[n - 1] / p * p + p;
  s[n] = s[n - 1] + a[n];
  if (a[1] % p == 0) now = find_gt(a[1] + 1);
  for (; now <= n && sum < ans;) {
    val = (a[now] - 1) / p * p + p;
    int posr = find_lt(val, now);
    if (a[posr] < val - max_add)
      sum += x * (posr - now + 1);
    else {
      int posl = find_gt(val - max_add, now, posr);
      sum += x * (posl - now);
      sum += y * ((long long)val * (posr - posl + 1) - (s[posr] - s[posl - 1]));
    }
    now = posr + 1;
  }
  return sum;
}
int main() {
  scanf("%d%I64d%I64d", &n, &x, &y);
  max_add = x / y;
  for (int i = 1; i <= n; ++i) scanf("%d", a + i);
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= n; ++i) s[i] = s[i - 1] + a[i];
  ma = a[n];
  Euler(ma + 1);
  ++n;
  for (int i = 1; i <= pt; ++i) ans = min(ans, work(prime[i]));
  printf("%I64d\n", ans);
  return 0;
}
