CF1593D1.All are Same
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
This problem is a simplified version of D2, but it has significant differences, so read the whole statement.
Polycarp has an array of n ( n is even) integers a1,a2,…,an . Polycarp conceived of a positive integer k . After that, Polycarp began performing the following operations on the array: take an index i ( 1≤i≤n ) and reduce the number ai by k .
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 k at which such a situation is possible, or print −1 if such a number can be arbitrarily large.
输入格式
The first line contains one integer t ( 1≤t≤10 ) — the number of test cases. Then t test cases follow.
Each test case consists of two lines. The first line contains an even integer n ( 4≤n≤40 ) ( n is even). The second line contains n integers a1,a2,…an ( −106≤ai≤106 ).
It is guaranteed that the sum of all n specified in the given test cases does not exceed 100 .
输出格式
For each test case output on a separate line an integer k ( k≥1 ) — the maximum possible number that Polycarp used in operations on the array, or −1 , if such a number can be arbitrarily large.
输入输出样例
输入#1
3 6 1 5 3 1 1 5 8 -1 0 1 -1 0 1 -1 0 4 100 -1000 -1000 -1000
输出#1
2 1 1100