#A2026C. 【KRUSKAL2026】Range Minimization
【KRUSKAL2026】Range Minimization
Problem Statement
The range of an array is defined as the difference between its maximum element and its minimum element.
You are given an integer array of length . You may perform the following operation any number of times, including zero times:
- Choose two distinct indices and ( and ), and update the array as follows:
Calculate the minimum possible range of after performing any finite number of operations.
Input Format
The input contains multiple test cases.
The first line contains an integer (), the number of test cases.
For each test case:
- The first line contains an integer (), the length of the array .
- The second line contains integers (), the elements of .
It is guaranteed that over all test cases.
Output Format
For each test case, output one integer on a separate line: the minimum possible range after performing any finite number of operations.
Sample
Sample Input
3
1
5
2
0 2
4
-1 9 5 8
Sample Output
0
2
1
Explanation
- In the first test case, the array contains only one element, so its range is always .