Parking


Submit solution

Points: 2
Time limit: 1.0s
Java 8 6.0s
Python 6.0s
Memory limit: 4M
Java 8 64M
Python 12M

Author:
Problem type

When shopping on Long Street, Michael usually parks his car at some random location, and then walks to the stores he needs. Can you help Michael choose a place to park which minimizes the distance he needs to walk on his shopping round? Long Street is a straight line, where all positions are integer. You pay for parking in a specific slot, which is an integer position on Long Street. Michael does not want to pay for more than one parking though. He is very strong, and does not mind carrying all the bags around, even when coming from multiple shops at once.

Input

The first line of input gives the number of test cases, \( 1 \leq t \leq 100\). There are two lines for each test case. The first gives the number of stores Michael wants to visit, \(1 \leq n \leq 20\), and the second gives their \(n\) integer positions on Long Street, \(0 \leq x_i \leq 99\).

Output

Output for each test case a line with the minimal distance Michael must walk given optimal parking.

Sample Input

2
4
24 13 89 37
6
7 30 41 14 39 42

Sample Output

152
70

Comments

There are no comments at the moment.