#C2632. Taco Array Difference Minimization

    ID: 45970 Type: Default 1000ms 256MiB

Taco Array Difference Minimization

Taco Array Difference Minimization

You are given t test cases. For each test case, you are given an integer n and a list of n integers representing an array a. You are allowed to perform operations that effectively reduce the overall difference between the maximum and minimum elements by 2.

Your task is to compute the minimum possible value of the difference between the maximum and minimum elements after performing the allowed operations. Formally, if the original difference is given by \(\max(a) - \min(a)\), then the resulting answer for each test case is:

[ \text{answer} = \max\big(0, (\max(a) - \min(a)) - 2\big) ]

Make sure that if the computed value becomes negative, you output 0 instead.

inputFormat

The first line 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 representing the elements of the array a.

outputFormat

For each test case, output a single line containing the minimum possible value of \(\max(a) - \min(a)\) after applying the allowed operations.

## sample
3
3
1 5 9
5
1 3 3 3 7
4
10 10 10 10
6

4 0

</p>