Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Power of Army

By kazi_nayeem · Limits 1s, 512 MB

Recently Chikanu declared war against Shukanu. To win the battle against Shukanu he wants to form an Army. As he wants to form a powerful Army, he needs a lot of soldiers.His best friend Thikanu will help him to find soldiers for his army. However, to fight against Shukanu, Chikanu needs a very powerful army. Before going to the battlefield Chikanu wants to measure the power of his army formed by NN soldiers.

Chikanu measures the power of his Army using the height of all soldiers. He defines the difference of height between the tallest soldier and the shortest soldier as the power of Army.

You will be given the height of all NN soldiers. You will have to output the power of Chikanu’s Army.

Input

First line contains an integer TT, denotes the number of test cases.

First line of each test case contains an integer NN, denotes the number of soldiers.

Following line contains NN integers. ii-th integer of this line represents the height of the ii-th solder and the height of a soldier is a positive integer less than or equal to 100000.

Constraints:

1T1001 \le T \le 100
2N10002 \le N \le 1000

Output

For each test case, print the power of the Army in a separate line.

Sample

InputOutput
1
5
2 4 5 3 2
3

Discussion

Statistics


90% Solution Ratio

kamran_11bEarliest, Jan '18

mebesusFastest, 0.0s

abuhuraira071Lightest, 0 B

bokaifShortest, 78B

Submit

Login to submit

Toph uses cookies. By continuing you agree to our Cookie Policy.