#K68947. Minimum Weight Difference

    ID: 32977 Type: Default 1000ms 256MiB

Minimum Weight Difference

Minimum Weight Difference

You are given a number of test cases. For each test case, you are given n boxes with different weight values. Your task is to find the minimum absolute difference between the weights of any two boxes. This is an important problem where differences between consecutive weights in sorted order are considered to determine the smallest gap.

Formally, if the weights are sorted as \(w_1 \le w_2 \le \cdots \le w_n\), you need to compute:

\[ \min_{2 \le i \le n} (w_i - w_{i-1}) \]

It is guaranteed that each test case will have at least two weights.

inputFormat

The input begins with an integer \(T\) (the number of test cases). For each test case, the first line contains an integer \(n\) indicating the number of boxes. The second line contains \(n\) space-separated integers representing the weights of the boxes.

Example:

3
5
1 3 6 9 12
4
10 20 30 40
3
15 5 25

outputFormat

For each test case, output a single line containing the minimum absolute difference between the weights of any two boxes.

Example output:

2
10
10
## sample
3
5
1 3 6 9 12
4
10 20 30 40
3
15 5 25
2

10 10

</p>