#C11284. Balanced Groups

    ID: 40583 Type: Default 1000ms 256MiB

Balanced Groups

Balanced Groups

Jasmine wants to divide her friends into two study groups. Her goal is to achieve as balanced groups as possible in terms of skill levels. More precisely, given the skill levels of n friends, you are required to partition them into two groups such that the maximum difference between any two adjacent skill levels in the sorted order of skills is minimized.

It turns out that the optimal value is exactly the minimum difference between any two consecutive skill levels after sorting. Your task is to compute that minimum difference for each test case.

The answer for a test case with only one friend is undefined but you can assume that each test case will contain at least 2 friends.

Mathematical Formulation:

Let the sorted skills be \(s_1 \leq s_2 \leq \cdots \leq s_n\). The answer is \[ \min_{2 \leq i \leq n} (s_i - s_{i-1}). \]

inputFormat

The first line of input contains an integer \(T\) (\(1 \le T \le 10\)), indicating the number of test cases.

For each test case, the first line contains an integer \(n\) (\(2 \le n \le 10^5\)), the number of friends. The second line contains \(n\) space-separated integers representing the skill levels of the friends.

It is guaranteed that the sum of \(n\) over all test cases does not exceed \(10^5\).

outputFormat

For each test case, output one line containing a single integer, the minimum possible maximum balance (i.e. the minimum difference between any two adjacent skill levels in sorted order).

## sample
1
4
1 2 3 4
1

</p>