#C11899. Maximum Difference Between Two Numbers

    ID: 41265 Type: Default 1000ms 256MiB

Maximum Difference Between Two Numbers

Maximum Difference Between Two Numbers

Given several test cases, each test case consists of an integer \(N\) and a sequence of \(N\) integers. Your task is to compute the maximum difference between any two distinct integers in the sequence. Formally, for an array \(A\), the answer is given by \(\max(A) - \min(A)\).

For instance, if \(A = [1, 2, 3, 4, 5]\), the maximum difference is \(5 - 1 = 4\). If all numbers are identical, the maximum difference will be \(0\).

inputFormat

The first line of input contains an integer \(T\) (the number of test cases). For each test case, the first line contains an integer \(N\) (the number of elements), and the following line contains \(N\) space-separated integers \(A_1, A_2, \dots, A_N\) where \(-10^9 \leq A_i \leq 10^9\).

outputFormat

For each test case, output a single line containing the maximum difference between any two distinct integers.

## sample
3
5
1 2 3 4 5
4
-10 20 30 40
3
100 200 300
4

50 200

</p>