Culinary specialist Monocarp has recently put n dishes into a broiler. He realizes that the I-th dish has its ideal cooking time equivalent to ti minutes. At any certain integer minute T Monocarp can put close to one dish out of the broiler. On the off chance that the I-th dish is put out at some moment T, its undesirable worth is |T−ti| — the outright contrast
Correct answer will be upvoted else Multiple Downvoted. Don't submit random answer. Computer science.
Culinary specialist Monocarp has recently put n dishes into a broiler. He realizes that the I-th dish has its ideal cooking time equivalent to ti minutes.
At any certain integer minute T Monocarp can put close to one dish out of the broiler. On the off chance that the I-th dish is put out at some moment T, its undesirable worth is |T−ti| — the outright contrast among T and ti. When the dish is out of the stove, it can't return in.
Monocarp should put every one of the dishes out of the stove. What is the base all out unsavory worth Monocarp can acquire?
Input
The principal line contains a solitary integer q (1≤q≤200) — the number of testcases.
Then, at that point, q testcases follow.
The principal line of the testcase contains a solitary integer n (1≤n≤200) — the number of dishes in the broiler.
The second line of the testcase contains n integers t1,t2,… ,tn (1≤ti≤n) — the ideal cooking time for each dish.
The amount of n over all q testcases doesn't surpass 200.
Output
Print a solitary integer for each testcase — the base complete terrible worth Monocarp can get when he puts out every one of the dishes out of the broiler. Recollect that Monocarp can just put the dishes out at positive integer minutes and close to one dish all of a sudden.
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 1 images