#d2554. 整齐的数组
整齐的数组
Equalizing Array
Problem Description
Polycarp has an array of length ( is even). Polycarp is also given a positive integer , and he begins performing the following operation on the array : choose an index and subtract from .
After Polycarp performs several operations (possibly ), all numbers in the array become equal. Find the largest such ; if can be arbitrarily large, output .
Input Format
The first line contains an integer , the number of test cases.
Each test case consists of two lines. The first line contains an even integer . The second line contains integers .
Output Format
For each test case, output one integer on a separate line — the largest value Polycarp can use to operate on the array — or if 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, , ( is even), , and the sum of does not exceed .