#P1437C. Chef Monocarp

    ID: 2821 Type: RemoteJudge 2000ms 256MiB Tried: 0 Accepted: 0 Difficulty: 6 Uploaded By: Tags>dpflowsgraph matchingsgreedymathsortings*1800

Chef Monocarp

Description

Chef Monocarp has just put nn dishes into an oven. He knows that the ii-th dish has its optimal cooking time equal to tit_i minutes.

At any positive integer minute TT Monocarp can put no more than one dish out of the oven. If the ii-th dish is put out at some minute TT, then its unpleasant value is Tti|T - t_i| — the absolute difference between TT and tit_i. Once the dish is out of the oven, it can't go back in.

Monocarp should put all the dishes out of the oven. What is the minimum total unpleasant value Monocarp can obtain?

The first line contains a single integer qq (1q2001 \le q \le 200) — the number of testcases.

Then qq testcases follow.

The first line of the testcase contains a single integer nn (1n2001 \le n \le 200) — the number of dishes in the oven.

The second line of the testcase contains nn integers t1,t2,,tnt_1, t_2, \dots, t_n (1tin1 \le t_i \le n) — the optimal cooking time for each dish.

The sum of nn over all qq testcases doesn't exceed 200200.

Print a single integer for each testcase — the minimum total unpleasant value Monocarp can obtain when he puts out all the dishes out of the oven. Remember that Monocarp can only put the dishes out at positive integer minutes and no more than one dish at any minute.

Input

The first line contains a single integer qq (1q2001 \le q \le 200) — the number of testcases.

Then qq testcases follow.

The first line of the testcase contains a single integer nn (1n2001 \le n \le 200) — the number of dishes in the oven.

The second line of the testcase contains nn integers t1,t2,,tnt_1, t_2, \dots, t_n (1tin1 \le t_i \le n) — the optimal cooking time for each dish.

The sum of nn over all qq testcases doesn't exceed 200200.

Output

Print a single integer for each testcase — the minimum total unpleasant value Monocarp can obtain when he puts out all the dishes out of the oven. Remember that Monocarp can only put the dishes out at positive integer minutes and no more than one dish at any minute.

Sample Input 1

6
6
4 2 4 4 5 2
7
7 7 7 7 7 7 7
1
1
5
5 1 2 4 3
4
1 4 4 4
21
21 8 1 4 1 5 21 1 8 21 11 21 11 3 12 8 19 15 9 11 13

Sample Output 1

4
12
0
0
2
21

Note

In the first example Monocarp can put out the dishes at minutes 3,1,5,4,6,23, 1, 5, 4, 6, 2. That way the total unpleasant value will be 43+21+45+44+65+22=4|4 - 3| + |2 - 1| + |4 - 5| + |4 - 4| + |6 - 5| + |2 - 2| = 4.

In the second example Monocarp can put out the dishes at minutes 4,5,6,7,8,9,104, 5, 6, 7, 8, 9, 10.

In the third example Monocarp can put out the dish at minute 11.

In the fourth example Monocarp can put out the dishes at minutes 5,1,2,4,35, 1, 2, 4, 3.

In the fifth example Monocarp can put out the dishes at minutes 1,3,4,51, 3, 4, 5.