#d2554. 整齐的数组

整齐的数组

Equalizing Array

Problem Description

Polycarp has an array a1,a2,…,ana_1, a_2, \dots, a_n of length nn (nn is even). Polycarp is also given a positive integer kk, and he begins performing the following operation on the array aa: choose an index i (1≤i≤n)i\ (1 \leq i \leq n) and subtract kk from aia_i.

After Polycarp performs several operations (possibly 00), all numbers in the array aa become equal. Find the largest such kk; if kk can be arbitrarily large, output −1-1.

Input Format

The first line contains an integer tt, the number of test cases.

Each test case consists of two lines. The first line contains an even integer nn. The second line contains nn integers a1,a2,…,ana_1, a_2, \dots, a_n.

Output Format

For each test case, output one integer k (k≥1)k\ (k \geq 1) on a separate line — the largest value Polycarp can use to operate on the array — or −1-1 if kk can be arbitrarily large.

Sample Input

3
6
1 5 3 1 1 5
8
-1 0 1 -1 0 1 -1 0
4
100 -1000 -1000 -1000

Sample Output

2
1
1100

Constraints

For all data, 1≤t≤101 \leq t \leq 10, 4≤n≤404 \leq n \leq 40 (nn is even), −106≤ai≤106-10^6 \leq a_i \leq 10^6, and the sum of nn does not exceed 100100.