#C1736. Planet Resource Surplus
Planet Resource Surplus
Planet Resource Surplus
You are given T test cases. In each test case, you are provided with data about a set of planets and their respective resource levels. For each test case, determine the surplus resource value, which is defined as the difference between the richest planet's resource amount and the second richest planet's resource amount.
If there is only one planet, then the surplus is defined to be 0. In cases where the two largest resource values are equal (for example, if the richest planet occurs at least twice), the surplus will also be 0.
The input is read from standard input (stdin) and your output should be written to standard output (stdout), with each test case's result printed on a new line.
inputFormat
The input begins with a single integer T, representing the number of test cases. For each test case, the first line contains an integer N, the number of planets. The next line contains N space-separated integers representing the resources available on each planet.
For example:
2 3 15 15 15 5 20 50 30 60 10
outputFormat
For each test case, output a single integer representing the surplus of the richest planet over the second richest planet. Each answer should be printed on a new line.
For the example above, the expected output would be:
0 10## sample
1
1
100
0
</p>