Codeforces Round 1014 (Div. 2)
A
Kamilka and the Sheep
Codeforces
800
原题
←B →
翻译中…

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

翻译中…

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

翻译中…

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 $t$ ($1 \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 $n$ ($2 \leq n \leq 100$), the number of sheep Kamilka has.

翻译中…

The second line of each test case contains $n$ distinct integers $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 $a_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=1$ works. In this case, the pleasure is $\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=3$. In this case, the pleasure is $\gcd(1+3, \ 5+3)=\gcd(4, \ 8)=4$. Thus, for this test case, the answer is $4$.

翻译中…

样例

Input #1
4
2
1 3
5
5 4 3 2 1
3
5 6 7
3
1 11 10
Output #1
2
4
2
10
InputCopy OutputCopy
题目信息
题号
2092A
时间限制
1 s
内存限制
256 MB
标签
贪心
数学
数论
排序

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。