Codeforces Round 432 (Div. 2, based on IndiaHacks Final Round 2017)
D
Arpa and a list of numbers
Codeforces
未评级
原题
← CE →
翻译中…

Arpa has found a list containing $*n*$ numbers. He calls a list bad if and only if it is not empty and gcd (see notes section for more information) of numbers in the list is $1$.

翻译中…

Arpa can perform two types of operations:

翻译中…
  • Choose a number and delete it with cost $*x*$.
  • Choose a number and increase it by $1$ with cost $*y*$.
翻译中…

Arpa can apply these operations to as many numbers as he wishes, and he is allowed to apply the second operation arbitrarily many times on the same number.

翻译中…

Help Arpa to find the minimum possible cost to make the list good.

翻译中…

Input

翻译中…

First line contains three integers $*n*$, $*x*$ and $*y*$ ($1 ≤ *n* ≤ 5·10^{5}$, $1 ≤ *x*, *y* ≤ 10^{9}$) — the number of elements in the list and the integers $*x*$ and $*y*$.

翻译中…

Second line contains $*n*$ integers $*a*_{1}, *a*_{2}, ..., *a*_{*n*}$ ($1 ≤ *a*_{*i*} ≤ 10^{6}$) — the elements of the list.

翻译中…

Output

翻译中…

Print a single integer: the minimum possible cost to make the list good.

翻译中…

Note

翻译中…

In example, number $1$ must be deleted (with cost $23$) and number $16$ must increased by $1$ (with cost $17$).

翻译中…

A gcd (greatest common divisor) of a set of numbers is the maximum integer that divides all integers in the set. Read more about gcd here.

翻译中…

样例

Input #1
4 23 17
1 17 17 16
Output #1
40
InputCopy OutputCopy
Input #2
10 6 2
100 49 71 73 66 96 8 60 41 63
Output #2
10
InputCopy OutputCopy
题目信息
题号
851D
时间限制
2 s
内存限制
256 MB

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。