#C8425. Minimum Training Sessions
Minimum Training Sessions
Minimum Training Sessions
You are given several test cases. In each test case, a group of participants is represented by their skill levels. In order for every participant to have a chance to win at least one match, the weakest player may require additional training sessions to improve their performance.
Each extra training session increases a participant's skill by 1. Therefore, the minimum number of extra training sessions required is equal to the difference between the highest and the lowest skill levels in the group. Mathematically, if the skill levels are \(s_1, s_2, \dots, s_n\), then the solution is given by:
\( \text{sessions} = \max\{s_1, s_2, \dots, s_n\} - \min\{s_1, s_2, \dots, s_n\} \)
Your task is to compute this value for each test case.
inputFormat
The input begins with a single integer \(T\) (the number of test cases). Each test case is described on one or more lines. For every test case, the first integer is \(n\) (the number of participants), followed by \(n\) space-separated integers representing the skill levels of the participants.
outputFormat
For each test case, output a single line containing the minimum number of extra training sessions needed, which is the difference between the highest and lowest skill levels.
## sample2
4 3 1 4 2
5 10 20 30 40 50
3
40
</p>