#K11566. Maximum Absolute Difference

    ID: 23497 Type: Default 1000ms 256MiB

Maximum Absolute Difference

Maximum Absolute Difference

Given an array of integers, your task is to determine the maximum absolute difference between any two distinct elements in the array.

Mathematically, if the array is \(a_1, a_2, \dots, a_n\), you are to compute the maximum value of \(|a_i - a_j|\) for all \(i \neq j\). It can be shown that the answer is \(\max(a) - \min(a)\), where \(\max(a)\) and \(\min(a)\) are the maximum and minimum elements in the array respectively.

This problem will test your ability to process multiple test cases and perform basic array operations efficiently.

inputFormat

The first line of input contains a single integer \(T\) representing the number of test cases. Each test case consists of two lines:

  • The first line contains an integer \(n\), the number of elements in the array.
  • The second line contains \(n\) space-separated integers.

outputFormat

For each test case, output a single line containing the maximum absolute difference of the array.

## sample
3
4
1 2 3 4
5
-10 -20 5 4 1
2
1000000000 -1000000000
3

25 2000000000

</p>