#K57227. Minimal Total Skill Difference

    ID: 30374 Type: Default 1000ms 256MiB

Minimal Total Skill Difference

Minimal Total Skill Difference

You are given t test cases. In each test case, you first receive an integer n indicating the number of teams, followed by n integers, where each integer represents the skill level of a team. The task is to reorder the teams such that the total difference between the skill levels of adjacent teams is minimized.

Observation: When the teams are sorted in non-decreasing order, the sum of the differences between adjacent teams is equal to the difference between the maximum and minimum skill levels. Thus, the problem reduces to computing max - min for each test case.

Input Format: The input is read from standard input. The first line contains the number of test cases t. For each test case, the first line is an integer n, and the following line contains n space-separated integers representing the team skill levels.

Output Format: For each test case, output a single integer on a new line representing the minimal total skill difference.

inputFormat

The first line of input contains an integer t (1 ≤ t ≤ 104), the number of test cases. Each test case consists of two lines: the first line contains an integer n (2 ≤ n ≤ 105), and the second line contains n space-separated integers representing the skill levels (each integer is between 1 and 109).

outputFormat

For each test case, print a single integer which is the minimal total skill difference achieved by ordering the teams in non-decreasing order. Each result should be printed on a new line.

## sample
3
4
1 3 6 8
5
4 3 1 9 7
2
5 10
7

8 5

</p>