#d1304. 整齐的数组2

整齐的数组2

Neat Array 2

Problem Description

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

After Polycarp performs some number of operations (possibly zero), at least half of the elements in aa become equal. Find the largest valid 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 then has two lines. The first contains an even integer nn. The second contains nn integers a1,a2,…,ana_1, a_2, \dots, a_n.

Output Format

For each test case, output a single integer kk (k≥1k \ge 1) on its own line — the largest number Polycarp can use to perform operations on the array — or −1-1 if kk can be arbitrarily large.

Sample Input

4
6
48 13 22 -15 16 35
8
-1 0 1 -1 0 1 -1 0
4
100 -1000 -1000 -1000
4
1 1 1 1

Sample Output

13
2
-1
-1

Constraints

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