Alawn has a length array of pairs
. Initially,
for all
.
Alawn loves arrays that satisfy the following property:
- The
values can be sorted by only swapping elements
and
where
.
A modification to the array consists of decreasing element 's
value by
. Can you determine the minimum number of modifications required to turn the array of pairs into one that Alawn loves?
Input Specification
The first line will contain
, the number of test cases.
test cases follow.
For each test case, the first line will contain two integers
, the number of elements in the array and the special value
.
The second line will contain integers,
, the elements of the array. Recall that
initially.
Output Specification
For each case, output the minimum number of modifications required on its own line.
Sample Input
2
5 1
1 2 3 4 5
5 4
1 2 5 3 6
Sample Output
0
1
Comments