#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 10, MN = 2e6 + 10;
vector<int> P;
bool pr[MN];
int n, arr[MN];
long long X, Y, C[MN], ps[MN], cnt[MN];
int main() {
  ios_base ::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n >> X >> Y;
  for (int i = 2; i < MN; ++i) {
    if (pr[i]) continue;
    P.push_back(i);
    for (int j = i + i; j < MN; j += i) pr[j] = true;
  }
  for (int i = 0; i < n; ++i) cin >> arr[i], ++cnt[arr[i]];
  for (int i = 0; i < MN - 1; ++i) C[i + 1] = C[i] + cnt[i];
  for (int i = 0; i < MN - 1; ++i) ps[i + 1] = ps[i] + 1ll * cnt[i] * i;
  long long ans = 1e18;
  for (auto x : P) {
    long long my = 0;
    if (x < 1500) {
      for (int i = 0; i < n; ++i)
        if (arr[i] % x) my += min(X, 1ll * (x - (arr[i] % x)) * Y);
    } else {
      for (int j = x; j < MN - 1; j += x) {
        int l = max(1ll * j - x + 1, j - X / Y);
        my += 1ll * Y * (1ll * (C[j] - C[l]) * j - (ps[j] - ps[l]));
        my += 1ll * X * (C[l] - C[j - x + 1]);
      }
    }
    ans = min(my, ans);
  }
  cout << ans << '\n';
  return 0;
}
