Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Minions and War

By emrul_mu · Limits 2s, 512 MB

In the land of Minion, there are N 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 P and decreasing a Minion’s power by 1 will cost Q.

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

Input

The input will be followed by an integer T, denoting the number of test case.

The first line of each test case will contain three integers N, P and Q. The second line will contain N integers denoting the power of Minions.

Constraints

1 ≤ T ≤ 10
1 ≤ N, P, Q ≤ 106
1 ≤ Minion’s Power ≤ 106
Sum of N over all the test cases ≤ 8 * 106

Output

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

Samples

InputOutput
1
3 1 1
1 2 3
2

Discussion