#include <bits/stdc++.h>
using namespace std;
int n;
long long x, y;
int X, Y;
int arr[500000];
long long cnt[1000001];
long long sum[1000001];
bool isPrime[1000001];
vector<long long> primes;
int main() {
  scanf("%d %d %d", &n, &X, &Y);
  x = X;
  y = Y;
  for (int i = 0; i < n; i++) {
    scanf("%d", arr + i);
    cnt[arr[i]]++;
    sum[arr[i]] += arr[i];
  }
  for (int i = 1; i <= 1000000; i++) {
    cnt[i] += cnt[i - 1];
    sum[i] += sum[i - 1];
  }
  if (cnt[1] == n) {
    cout << 1LL * min(x, y) * (n - 1) + min(x, y) << endl;
    return 0;
  }
  for (int i = 2; i <= 1000000; i++) isPrime[i] = true;
  for (int i = 2; i <= 1000000; i++) {
    if (isPrime[i]) {
      primes.push_back(i);
      for (int j = 2; j * i <= 1000000; j++) isPrime[j * i] = false;
    }
  }
  long long ans = 2000000000000000000;
  for (int i = 0; i < primes.size(); i++) {
    if (primes[i] * primes[i] <= 1000000) {
      long long cur = 0;
      for (int j = 0; j < n; j++) {
        long long add = 0;
        if (arr[j] % primes[i] != 0) add = primes[i] - (arr[j] % primes[i]);
        cur += min(1LL * y * add, 1LL * x);
      }
      ans = min(ans, cur);
    } else {
      if (primes[i] == 103357) {
      }
      long long cur = 0;
      for (int j = 1; j * primes[i] < 1000000 + primes[i]; j++) {
        long long num = primes[i] * j;
        long long from = max(num - primes[i], num - x / y - 1);
        long long prev = num - primes[i];
        if (from > 1000000) {
          cur += (cnt[1000000] - cnt[prev]) * x;
        } else {
          from = max(from, prev);
          cur += (cnt[from] - cnt[prev]) * x +
                 ((cnt[min(1000000LL, num)] - cnt[from]) * primes[i] * j -
                  (sum[min(1000000LL, num)] - sum[from])) *
                     y;
        }
      }
      ans = min(ans, cur);
    }
  }
  cout << ans << endl;
  return 0;
}
