Huseyn's Friends
Execution time limit is 1 second
Runtime memory usage limit is 128 megabytes
The student of ADA University Huseyn Hajiyev is moving to Seul to study at Chung-Ang University. He has many friends there, all of them living on Heukseok-ro street. Since he will visit all his friends very often, he is trying to find a house close to them.
Huseyn wants to minimize the total distance to all of his friends.
Input
The first line contains the number of test cases.
For each test case, you are given the integer number of friends and the house numbers where they live. Note that several friends could live in the same house.
Output
For each test case, print the minimal sum of distances from the optimal Huseyn’s house to each one of his friends. The distance between two house numbers and is .
Examples
Input #1
Answer #1
Submissions 275
Acceptance rate 56%