Limits 2s, 512 MB

In the land of Minion, there are NN Minions. They have their own power to survive themselves from enemy.

The power of every Minion may not always be equal. But, their power must to be equal as you don't want a war among themselves. So, you need to make the every Minion's power equal.

You can increase or decrease any Minion's power by 1 as many time as you want.

But nothing is free here! Increasing a Minion's power by 1 will cost PP and decreasing a Minion's power by 1 will cost QQ.

You need to find the minimum cost to make every Minion's power equal.

Input

The input will be followed by an integer TT (1T101 ≤ T ≤ 10), denoting the number of test case.

The first line of each test case will contain three integers NN, PP and QQ (1N,P,Q1061 ≤ N, P, Q ≤ 10^6). The second line will contain NN integers denoting the power of Minions (1Minion’s Power1061 ≤ \text{Minion's Power} ≤ 10^6).

Sum of NN over all the test cases 8×106≤ 8 \times 10^6.

Output

For each test case, the only line of the output will contain the minimum cost to make every Minion’s power equal.

Sample

InputOutput
1
3 1 1
1 2 3
2

Submit

Login to submit.

Statistics

63% Solution Ratio
ehsan_sShuvoEarliest, Mar '18
nusuBotFastest, 0.8s
moinul.shaonLightest, 4.1 MB
IOI_StfuFfsShortest, 665B
Toph uses cookies. By continuing you agree to our Cookie Policy.