Problem Statement

There are n piles of stones. Each pile of stone has a height Ai. Mickey and Minnie are

bored, so they decide to play a game. The game is as follows -

Minnie will give Mickey an integer k. Now Mickey has to make the difference between

the height of the highest pile and the lowest equal to k.

In a move, Mickey can either increase the height of any pile by one or decrease by one.

Find the minimum number of moves Mickey will need.

Note: Answers can be large use long long.

Input Format

The first line of input consists of a single integer t , the number of test cases.

The first line of each test case contains two integers n and k number of piles and value of k respectively.

The second line of each test case contains n space separated integers, the height of the ith pile.

It is guaranteed that the sum of n over all test cases does not exceed 2*10^5.

Output Format

For each test case, print the minimum number of moves required to do the task.

Sample Testcase #0

Testcase Input

1

5 2

1 2 3 4 5

Testcase Output

2

Explanation

In the first sample, we can increase A1 by 1 and decrease A5 by 1. The final

configuration will become [2,2,3,4,4]. The answer will be 2.

Sample Testcase #1

Testcase Input

3

5 10

5 5 5 5 5

10 0

1 2 3 4 5 6 7 8 9 10

72

1 1 1 4 7 7 7

Testcase Output

0

25

12