[Solution] All are Same solution codeforces | Codeforces Round #748

All are Same solution codeforces


This problem is a simplified version of D2, but it has significant differences, so read the whole statement.

Polycarp has an array of nn (nn is even) integers a1,a2,,ana1,a2,…,an. Polycarp conceived of a positive integer kk. After that, Polycarp began performing the following operations on the array: take an index ii (1in1≤i≤n) and reduce the number aiai by kk.

After Polycarp performed some (possibly zero) number of such operations, it turned out that all numbers in the array became the same. Find the maximum kk at which such a situation is possible, or print 1−1 if such a number can be arbitrarily large.

All are Same solution codeforces

Input

The first line contains one integer tt (1t101≤t≤10) — the number of test cases. Then tt test cases follow.

Each test case consists of two lines. The first line contains an even integer nn (4n404≤n≤40). The second line contains nn integers a1,a2,ana1,a2,…an (106ai106−106≤ai≤106).

It is guaranteed that the sum of all nn specified in the given test cases does not exceed 100100.

All are Same solution codeforces

Output

For each test case output on a separate line an integer kk (k1k≥1) — the maximum possible number that Polycarp used in operations on the array, or 1−1, if such a number can be arbitrarily large.

All are Same solution codeforces

Example

input

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

All are Same solution codeforces

output

Copy
2
1
1100

 


All are Same solution codeforcesYet another MEX problem solution codechefYet another MEX problem solution codechefYet another MEX problem solution codechef

Leave a Comment