CF2092A.Kamilka and the Sheep

传统题 时间 2000 ms 内存 256 MiB 3 尝试 1 已通过 1 标签

Kamilka and the Sheep

Kamilka has a flock of nn sheep, the ii-th of which has a beauty level of aia_i. All aia_i are distinct. Morning has come, which means they need to be fed. Kamilka can choose a non-negative integer dd and give each sheep dd bunches of grass. After that, the beauty level of each sheep increases by dd.

In the evening, Kamilka must choose exactly two sheep and take them to the mountains. If the beauty levels of these two sheep are xx and yy (after they have been fed), then Kamilka's pleasure from the walk is equal to gcd(x,y)\gcd(x, y), where gcd(x,y)\gcd(x, y) denotes the greatest common divisor (GCD) of integers xx and yy.

The task is to find the maximum possible pleasure that Kamilka can get from the walk.

Input

Each test consists of several test cases. The first line contains one integer tt (1t5001 \le t \le 500), the number of test cases. The description of the test cases follows.

The first line of each test case contains one integer nn (2n1002 \leq n \leq 100), the number of sheep Kamilka has.

The second line of each test case contains nn distinct integers a1,a2,,an (1ai109)a_1, a_2, \ldots, a_n \ (1 \le a_i \le 10^9) — the beauty levels of the sheep.

It is guaranteed that all aia_i are distinct.

Output

For each test case, output a single integer: the maximum possible pleasure that Kamilka can get from the walk.

Note

In the first test case, d=1d=1 works. In this case, the pleasure is gcd(1+1, 1+3)=gcd(2, 4)=2\gcd(1+1, \ 1+3)=\gcd(2, \ 4)=2. It can be shown that a greater answer cannot be obtained.

In the second test case, let's take d=3d=3. In this case, the pleasure is gcd(1+3, 5+3)=gcd(4, 8)=4\gcd(1+3, \ 5+3)=\gcd(4, \ 8)=4. Thus, for this test case, the answer is 44.

Samples

4
2
1 3
5
5 4 3 2 1
3
5 6 7
3
1 11 10
2
4
2
10

在线编程 IDE

建议全屏模式获得最佳体验