#K41997. Minimum Adjacent Difficulty Gap

    ID: 26989 Type: Default 1000ms 256MiB

Minimum Adjacent Difficulty Gap

Minimum Adjacent Difficulty Gap

You are given several test cases. In each test case, you have a list of problems with their corresponding difficulty ratings. Your task is to rearrange the difficulties in such a way that you then compute the minimum gap between consecutive problems. Formally, for each test case with n difficulties \(d_1, d_2, \ldots, d_n\), after sorting them in non-decreasing order, determine \(\min_{1 \leq i < n} \{d_{i+1} - d_i\}\).

Input Format: The input starts with an integer \(t\) on the first line representing the number of test cases. For each test case, the first line contains an integer \(n\) (where \(n \ge 2\)) denoting the number of problems. The following line contains \(n\) space-separated integers representing the difficulty ratings.

Output Format: For each test case, output a single integer on a new line which is the minimum difference between any two consecutive difficulties in the sorted order.

Example:

Input:
3
3
1 4 7
4
10 20 30 40
5
5 3 8 1 6

Output: 3 10 1

</p>

The first test case: Sorting [1, 4, 7] gives differences 3 and 3, so the answer is 3.

inputFormat

The input is read from standard input (stdin) with the following format:

  1. The first line contains an integer (t) denoting the number of test cases.
  2. For each test case:
    • The first line contains an integer (n) (at least 2), the number of problems.
    • The second line contains (n) space-separated integers representing the difficulty ratings.

Example: 3 3 1 4 7 4 10 20 30 40 5 5 3 8 1 6

outputFormat

For each test case, output the minimum difference between any two consecutive elements after sorting the list of difficulties. Each result should be printed on its own line to standard output (stdout).

Example: 3 10 1## sample

1
2
0 1000000000
1000000000

</p>