1593D1.md (1580B)
1 Source: https://codeforces.com/problemset/problem/1593/D1 2 3 D1. All are Same 4 5 time limit per test 6 7 1 second 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 standard input 16 17 output 18 19 standard output 20 21 This problem is a simplified version of D2, but it has significant differences, so read the whole statement. 22 23 Polycarp has an array of $n$ ($n$ is even) integers $a_1, a_2, \dots, a_n$. Polycarp conceived of a positive integer $k$. After that, Polycarp began performing the following operations on the array: take an index $i$ ($1 \le i \le n$) and reduce the number $a_i$ by $k$. 24 25 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. 26 27 Input 28 29 The first line contains one integer $t$ ($1 \le t \le 10$) — the number of test cases. Then $t$ test cases follow. 30 31 Each test case consists of two lines. The first line contains an even integer $n$ ($4 \le n \le 40$) ($n$ is even). The second line contains $n$ integers $a_1, a_2, \dots a_n$ ($-10^6 \le a_i \le 10^6$). 32 33 It is guaranteed that the sum of all $n$ specified in the given test cases does not exceed $100$. 34 35 Output 36 37 For each test case output on a separate line an integer $k$ ($k \ge 1$) — the maximum possible number that Polycarp used in operations on the array, or $-1$, if such a number can be arbitrarily large. 38 39 Example 40 41 Input 42 43 ``` 44 3 45 6 46 1 5 3 1 1 5 47 8 48 -1 0 1 -1 0 1 -1 0 49 4 50 100 -1000 -1000 -1000 51 ``` 52 53 Output 54 55 ``` 56 2 57 1 58 1100 59 ```