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 $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$.

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.


-----Input-----

The first line contains one integer $t$ ($1 \le t \le 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 \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$).

It is guaranteed that the sum of all $n$ specified in the given test cases does not exceed $100$.


-----Output-----

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.


-----Examples-----

Input
3
6
1 5 3 1 1 5
8
-1 0 1 -1 0 1 -1 0
4
100 -1000 -1000 -1000
Output
2
1
1100


-----Note-----

None

Difficulty: EASY

Solutions:
from math import gcd
for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	k = 0
	b = min(a)
	for i in range(n):
		k = gcd(k, a[i] - b)
	print(-1) if len(set(a)) == 1 else print(k)


from math import gcd

def abs(x):
	if x < 0:
		return -x
	return x

def gcd_list(b, n):
	while n != 1:
		c = gcd(b[-1], b[-2])
		b.pop()
		b.pop()
		b.append(c)
		n -= 1
	return b[0]
for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = [abs(a[0] - a[i]) for i in range(1, n)]
	c = gcd_list(b, n - 1)
	if c == 0:
		print(-1)
	else:
		print(c)


n = int(input())

def computeGCD(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
for i in range(n):
	size = int(input())
	tab = [int(i) for i in input().split()]
	if tab.count(tab[0]) == len(tab):
		print(-1)
	else:
		k = 10000000000000000
		mini = min(tab)
		allValues = []
		for val in tab:
			allValues.append(val - mini)
		num1 = allValues[0]
		num2 = allValues[1]
		gcd = computeGCD(num1, num2)
		for i in range(2, len(allValues)):
			gcd = computeGCD(gcd, allValues[i])
		print(gcd)


import math
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	mn = min(a)
	if a.count(mn) == len(a):
		print(-1)
	else:
		k = 0
		for i in a:
			k = math.gcd(k, i - mn)
		print(k)


def gcd(a, b):
	if a < b:
		(a, b) = (b, a)
	if b == 0:
		return a
	while a % b != 0:
		(a, b) = (b, a % b)
	return b
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	if len(list(set(a))) == 1:
		print(-1)
		continue
	d = []
	for i in range(n):
		for j in range(i + 1, n):
			d.append(abs(a[i] - a[j]))
	e = gcd(d[0], d[1])
	for i in range(2, len(d)):
		e = gcd(e, d[i])
	print(e)


import math
t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	ans = 0
	for i in range(n):
		for j in range(i):
			if a[i] != a[j]:
				ans = math.gcd(ans, abs(a[i] - a[j]))
	print(ans if ans else -1)


def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)
t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	ans = 0
	for i in range(n - 1):
		d = l[i + 1] - l[i]
		if ans == 0:
			ans = d
		else:
			ans = gcd(ans, d)
	if ans == 0:
		ans = -1
	print(ans)


from math import gcd
from functools import reduce

def find_gcd(list):
	x = reduce(gcd, list)
	return x
T = int(input())
for t in range(T):
	n = int(input())
	array = list(map(int, input().split(' ')))
	m = min(array)
	scaled = [x - m for x in array]
	res = find_gcd(scaled)
	if not res:
		print(-1)
	else:
		print(res)


import math

def read_nums():
	return [int(x) for x in input().split()]

def gcd(nums):
	if len(nums) == 1:
		return nums[0]
	res = math.gcd(nums[0], nums[1])
	for i in range(2, len(nums)):
		res = math.gcd(res, nums[i])
	return res

def solve():
	(n,) = read_nums()
	nums = set(read_nums())
	if len(nums) == 1:
		print(-1)
		return
	target = min(nums)
	print(gcd([x - target for x in nums if x != target]))

def main():
	(t,) = read_nums()
	for _ in range(t):
		solve()
main()


import math
for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	s = sorted(list(set(a)))
	if len(s) == 1:
		print(-1)
	else:
		b = []
		for i in range(1, len(s)):
			b.append(s[i] - s[i - 1])
		m = min(b)
		for i in b:
			m = math.gcd(m, i)
		print(m)


def find_gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	temp = max(arr)
	arr.sort()
	l = []
	for i in range(len(arr) - 1):
		l.append(temp - arr[i])
	gcd = find_gcd(l[0], l[1])
	for i in range(2, len(l)):
		gcd = find_gcd(gcd, l[i])
	if arr[0] == arr[n - 1]:
		print(-1)
	else:
		print(gcd)


def find_gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
for _ in range(int(input())):
	n = int(input())
	lst = list(map(int, input().split()))
	if len(set(lst)) == 1:
		print(-1)
		continue
	m = min(lst)
	l = []
	for i in lst:
		l.append(i - m)
	num1 = l[0]
	num2 = l[1]
	gcd = find_gcd(num1, num2)
	for i in range(2, len(l)):
		gcd = find_gcd(gcd, l[i])
	print(gcd)


def getNod(a, b):
	while a != 0 and b != 0:
		if a > b:
			a %= b
		else:
			b %= a
	return a + b
for t in range(int(input())):
	n = int(input())
	lst = list(map(int, input().split()))
	m = min(lst)
	r = [0] * n
	for i in range(n):
		if lst[i] != m:
			r[i] = lst[i] - m
	nod = r[0]
	for i in range(1, n):
		nod = getNod(nod, r[i])
	if len(set(lst)) == 1:
		print(-1)
	else:
		print(nod)


from sys import stdin
import bisect
input = stdin.readline
ip = lambda : input().rstrip('\n')
IP = lambda : list(map(int, ip().split()))

def gcd(a, b):
	while b:
		tmp = a % b
		a = b
		b = tmp
	return a
for i in range(int(ip())):
	n = int(ip())
	lst = sorted(IP())
	dif = set()
	for i in range(1, n):
		dif.add(lst[i] - lst[0])
	if all([i == 0 for i in dif]):
		print(-1)
	else:
		for i in dif:
			if i != 0:
				ret = i
				break
		for i in dif:
			if i != 0:
				ret = gcd(ret, i)
		print(ret)


from sys import stdin
input = stdin.readline

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)
for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	s = set(a)
	if len(s) == 1:
		print(-1)
	else:
		mini = min(a)
		s.remove(mini)
		dif = []
		diff = 10000000
		for i in a:
			dif.append(i - mini)
		num1 = dif[0]
		num2 = dif[1]
		vgcd = gcd(num1, num2)
		for i in range(2, len(dif)):
			vgcd = gcd(vgcd, dif[i])
		print(vgcd)


import sys
import math
input = sys.stdin.readline

def solve():
	input()
	a = set(map(int, input().split()))
	if len(a) == 1:
		print(-1)
	else:
		b = sorted(a)
		c = [y - x for (x, y) in zip(b, b[1:])]
		ans = c[0]
		for x in c[1:]:
			ans = math.gcd(ans, x)
		print(ans)
for _ in range(int(input())):
	solve()


import sys
input = lambda : sys.stdin.readline().rstrip('\r\n')
import math
inp_vars_int = lambda : map(int, input().split())
inp_list_int = lambda : list(map(int, input().split()))
t = int(input())
for _ in range(t):
	n = int(input())
	a = sorted(inp_list_int())
	if len(set(a)) == 1:
		print(-1)
		continue
	d = [a[i] - a[i - 1] for i in range(1, n)]
	res = d[0]
	for d2 in d[1:]:
		res = math.gcd(res, d2)
		if res == 1:
			break
	print(res)


def nod(a, b):
	if a != b and b != 0:
		return nod(b, a % b)
	else:
		return a
t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	w = min(a)
	no = max(a) - w
	if no == 0:
		print(-1)
	else:
		for j in a:
			if j != w:
				no = nod(no, j - w)
		print(no)


res = []
for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	tmp = []
	for j in range(1, n):
		tmp.append(abs(a[j - 1] - a[j]))
	tmp.sort()
	d = tmp[-1]
	dels = set()
	for j in range(1, int(d ** 0.5) + 1):
		if d % j == 0:
			dels.add(j)
			dels.add(d // j)
	all_dels = []
	for j in dels:
		flag = True
		for k in tmp:
			if k % j != 0:
				flag = False
				break
		if flag:
			all_dels.append(j)
	if len(all_dels) == 0:
		res.append(-1)
	else:
		res.append(max(all_dels))
print(*res, sep='\n')


import sys
from math import *
for _ in range(int(sys.stdin.readline())):
	n = int(sys.stdin.readline())
	lst = list(map(int, sys.stdin.readline().split()))
	d = abs(lst[1] - lst[0])
	for i in range(1, n - 1):
		recent = abs(lst[i + 1] - lst[i])
		d = gcd(d, recent)
	if d == 0:
		print(-1)
	else:
		print(d)


from sys import setrecursionlimit
setrecursionlimit(1000000)

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	mi = min(a)
	ans = 0
	for i in range(n):
		a[i] = a[i] - mi
		ans = gcd(ans, a[i])
	if ans == 0:
		print(-1)
	else:
		print(int(ans))


def gcd(a, b):
	while a != 0 and b != 0:
		if a < b:
			b = b % a
		else:
			a = a % b
	return a if a else b
t = int(input())
for i in range(t):
	n = int(input())
	a = [int(n) for n in input().split()]
	m = min(a)
	ans = 0
	for j in a:
		ans = gcd(ans, j - m)
	print(ans or -1)


from math import gcd

def solve(n, ls):
	m = min(ls)
	g = []
	for ai in ls:
		if ai == m:
			continue
		g.append(ai - m)
	if not g:
		return -1
	gc = g[0]
	for gi in g[1:]:
		gc = gcd(gi, gc)
	return gc
t = int(input().strip())
inputs = []
for _ in range(t):
	n = int(input().strip())
	ls = list(map(int, input().strip().split()))
	inputs.append((n, ls))
for (n, ls) in inputs:
	print(solve(n, ls))


t = int(input())

def gcd(a, b):
	if not a * b:
		return a + b
	if a > b:
		return gcd(a % b, b)
	else:
		return gcd(a, b % a)
for _ in range(t):
	n = int(input())
	L = [*map(int, input().split())]
	mn = min(L)
	ans = -1000000000.0
	for el in L:
		if el != mn:
			if ans == -1000000000.0:
				ans = el - mn
			else:
				ans = gcd(ans, el - mn)
	if ans == -1000000000.0:
		print(-1)
	else:
		print(ans)


import math

def main() -> None:
	for t in range(int(input())):
		n = int(input())
		a = list(set([int(x) for x in input().split()]))
		a.sort()
		n = len(a)
		if n == 1:
			print(-1)
		else:
			ans = a[1] - a[0]
			for i in range(n - 1):
				ans = math.gcd(ans, a[i + 1] - a[i])
			print(ans)
main()


T = int(input())
for _ in range(T):
	n = int(input())
	A = list(map(int, input().split()))
	D = set(A)
	B = []
	for i in D:
		B.append(i)
	B.sort()
	ans = 9999999999
	if len(B) == 2:
		print(abs(B[0] - B[1]))
		continue
	if len(B) == 1:
		print(-1)
		continue
	C = []

	def gcd(x, y):
		while y:
			(x, y) = (y, x % y)
		return x
	for i in range(1, len(B)):
		t = abs(B[0] - B[i])
		C.append(t)
	a = C[0]
	b = C[1]
	ans = gcd(a, b)
	for i in range(2, len(C)):
		ans = gcd(ans, C[i])
	print(ans)


from math import gcd

def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		a = list(map(int, input().split()))
		a.sort()
		ans = -1
		for i in range(1, n):
			diff = a[i] - a[i - 1]
			if diff == 0:
				continue
			if ans == -1:
				ans = diff
			else:
				ans = gcd(ans, diff)
		print(ans)
main()


from math import gcd
for s in range(int(input())):
	n = int(input())
	flag = 0
	li = [int(i) for i in input().split()]
	(g, k) = (0, li[0])
	for i in range(1, n):
		if li[i] != li[0]:
			flag = 1
			break
	if flag == 0:
		print(-1)
	else:
		for i in range(1, n):
			g = gcd(g, k - li[i])
		print(g)


from math import gcd
t = int(input())
for _ in range(t):
	n = int(input())
	arr = set(map(int, input().split()))
	if len(arr) == 1:
		print(-1)
		continue
	arr = sorted(arr)
	res = arr[1] - arr[0]
	for i in range(2, len(arr)):
		res = gcd(res, arr[i] - arr[i - 1])
	print(res)


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	mn = l[0]
	m = list(map(lambda x: x - mn, l))
	x = -1
	c = 0
	f = 1
	while f == 1:
		f = 0
		for i in range(n):
			if m[i] != 0 and c == 0:
				x = m[i]
				c = 1
			elif m[i] != 0:
				if m[i] % x == 0:
					continue
				else:
					x = m[i] % x
					f = 1
					break
	print(x)


import math
t = int(input())
for tc in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	res = 0
	for i in range(1, n):
		res = math.gcd(res, arr[i] - arr[i - 1])
	if res == 0:
		print(-1)
	else:
		print(res)


import math
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	mn = min(a)
	g = 0
	for i in a:
		g = math.gcd(g, i - mn)
	if g == 0:
		print(-1)
	else:
		print(g)


def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def func():
	n = int(input())
	l = sorted(list(map(int, input().split())))
	if l[0] == l[-1]:
		print(-1)
		return
	g = 0
	for i in range(1, len(l)):
		x = l[i] - l[0]
		g = gcd(g, x)
	print(g)
t = int(input())
for i in range(t):
	func()


from math import gcd
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	if len(a) == 1:
		print(-1)
		continue
	a = sorted(a)
	ans = a[1] - a[0]
	for i in range(2, len(a)):
		ans = gcd(ans, a[i] - a[i - 1])
	if ans == 0:
		print(-1)
		continue
	print(ans)


from math import gcd
t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	diff = []
	p = min(arr)
	for o in range(n):
		if arr[o] == p:
			continue
		diff.append(arr[o] - p)
	g = 0
	for i in range(len(diff)):
		g = gcd(g, diff[i])
	if g == 0:
		print(-1)
	else:
		print(g)


from math import gcd
from collections import Counter
from sys import stdin as read, stdout as out
from bisect import bisect_left as bl, bisect_right as br

def get_int():
	return int(read.readline())

def get_int_more():
	return map(int, read.readline().split())

def get_list():
	return list(map(int, read.readline().strip().split()))

def get_strl():
	return list(read.readline()[:-1])

def get_str():
	return read.readline()

def write(result):
	out.write(str(result))

def write_list(lst):
	out.write(' '.join(map(str, lst)))
	out.write('\n')

def solve():
	n = get_int()
	k = 0
	lst = get_list()
	for i in range(1, n):
		k = gcd(k, lst[i] - lst[i - 1])
	if k == 0:
		print(-1)
	else:
		print(k)

def main():
	t = get_int()
	while t:
		solve()
		t -= 1
main()


def fun(a, b):
	mn = min(a, b)
	mx = max(a, b)
	if mn == mx or mn == 0:
		return max(1, mx)
	ds = int(mx / mn)
	return fun(mn, mx - ds * mn)

def solve():
	n = int(input())
	a = list(map(int, input().split()))
	mn = min(a)
	v = []
	val = -1
	for i in a:
		dif = i - mn
		if dif:
			v.append(dif)
		if dif == 0:
			continue
		if val < 0:
			val = dif
		else:
			val = fun(val, dif)
	if len(str(val)) < 1e+18:
		print(int(val))
	else:
		print(-1)
t = int(input())
for t1 in range(t):
	solve()


from math import gcd
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	if a.count(a[0]) == n:
		print(-1)
	else:
		a.sort()
		g = 0
		x = 1
		maxi = 1
		for i in range(n - 2, -1, -1):
			g = gcd(g, a[i + 1] - a[i])
		print(max(g, 1))


import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)

def gcd(x, y):
	if y == 0:
		return x
	else:
		return gcd(y, x % y)
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	s = set(list(map(int, input().split())))
	sl = list(s)
	sl.sort()
	t = sl[0]
	for i in range(len(sl)):
		sl[i] -= t
	if len(sl) == 1:
		ans = -1
	elif len(sl) == 2:
		ans = sl[1]
	else:
		ans = sl[1]
		for i in range(2, len(sl)):
			ans = gcd(ans, sl[i])
	print(ans)


import math
import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	m = min(a)
	res = []
	for i in range(n):
		if a[i] != m:
			res.append(a[i] - m)
	if not res:
		print(-1)
		continue
	gcd = res[0]
	for i in range(1, len(res)):
		gcd = math.gcd(res[i], gcd)
	print(gcd)


from math import gcd
for _ in range(int(input())):
	n = int(input())
	li = list(map(int, input().split()))
	li.sort()
	ans = []
	for i in range(1, n):
		if li[i] - li[i - 1] != 0:
			ans.append(li[i] - li[i - 1])
	if len(ans) == 0:
		print(-1)
		continue
	if ans.count(ans[0]) == len(ans):
		print(min(ans))
	else:
		gc = ans[0]
		for i in range(1, len(ans)):
			gc = gcd(ans[i], gc)
		print(gc)


from math import gcd
for _ in range(int(input())):
	n = int(input())
	a = set(map(int, input().split()))
	mn = min(a)
	li = []
	cnt = -1
	for i in a:
		cnt += 1
		if i != mn:
			li.append(i - mn)
	if cnt == 1:
		print(li[0])
		continue
	elif cnt == 0:
		print(-1)
		continue
	num1 = li[0]
	num2 = li[1]
	gc = gcd(num1, num2)
	for i in range(2, cnt):
		gc = gcd(gc, li[i])
	print(gc)


from math import gcd
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	if len(set(arr)) == 1:
		print(-1)
		continue
	mini = min(arr)
	GCD = None
	for val in arr:
		if val != mini:
			if GCD is None:
				GCD = val - mini
			else:
				GCD = gcd(GCD, val - mini)
	print(GCD)


from sys import stdin
input = stdin.readline
test = int(input())

def gcd(a, b):
	if a % b == 0:
		return b
	return gcd(b, a % b)
for _ in range(test):
	n = int(input())
	arr = list(map(int, input().split()))
	(val, i, g) = (min(arr), 0, 0)
	while i < n and arr[i] == val:
		i += 1
	if i == n:
		print(-1)
	else:
		g = arr[i] - val
		for j in range(i + 1, n):
			if arr[j] != val:
				g = gcd(arr[j] - val, g)
		print(g)


from math import gcd
for _ in range(int(input())):
	n = int(input())
	spic = list(map(int, input().split()))
	fl = False
	ans = 0
	k = min(spic)
	for i in range(n):
		if spic[i] != spic[i - 1]:
			fl = True
		ans = gcd(ans, spic[i] - k)
	if ans != 0:
		print(ans)
	else:
		print(-1)


from math import gcd
for i in range(int(input())):
	N = int(input())
	lst = list(map(int, input().split()))
	p = []
	t = min(lst)
	if len(list(set(lst))) == 1:
		print(-1)
	else:
		for h in lst:
			if h != t:
				p.append(h - t)
		m = p[0]
		for h in p[1:]:
			m = gcd(m, h)
		print(m)


def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	a.sort()
	temp = -1000000000000
	for i in a:
		if i > temp:
			temp = i
	l = []
	for i in range(len(a) - 1):
		l.append(temp - a[i])
	_gcd = gcd(l[0], l[1])
	for i in range(2, len(l)):
		_gcd = gcd(_gcd, l[i])
	print(_gcd if a[0] != a[n - 1] else '-1')


from math import *

def readInt():
	return int(input())

def readInts():
	return [int(i) for i in input().split(' ')]

def readString():
	return input()

def readStrings():
	return input().split(' ')
T = readInt()
for tc in range(T):
	n = readInt()
	a = readInts()
	diffs = [abs(a[i + 1] - a[i]) for i in range(len(a) - 1)]
	res = diffs[0]
	for d in diffs:
		res = gcd(res, d)
	if res == 0:
		print(-1)
	else:
		print(res)


from math import *
from functools import *

def readInt():
	return int(input())

def readInts():
	return [int(i) for i in input().split(' ')]
for _ in range(readInt()):
	(n, a) = (readInt(), readInts())
	diffs = [abs(a[i + 1] - a[i]) for i in range(len(a) - 1)]
	res = reduce(gcd, diffs, diffs[0])
	print(res if res else -1)


import math
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	a = min(arr)
	if arr.count(a) == n:
		print(-1)
		continue
	for i in range(n):
		arr[i] = arr[i] - a
	gcd = arr[0]
	for i in arr:
		gcd = math.gcd(gcd, i)
	print(gcd)


def gsd(a, b):
	while a % b != 0:
		a %= b
		(a, b) = (b, a)
	return b
t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(s) for s in input().split()]
	m = min(a)
	for i in range(n):
		a[i] -= m
	d = 0
	for el in a:
		if el != 0:
			d = el
			break
	if d == 0:
		print(-1)
	else:
		for el in a:
			d = gsd(el, d)
			if d == 1:
				break
		print(d)


from math import gcd
t = int(input())
for _ in range(t):
	n = input()
	a = list(map(int, input().split()))
	minimal = min(a)
	current_gcd = 0
	for elem in a:
		if elem != minimal:
			current_gcd = gcd(current_gcd, abs(minimal - elem))
	if current_gcd == 0:
		print(-1)
	else:
		print(current_gcd)


from collections import Counter, deque, defaultdict
from math import *
mod = 1000000007

def solve():
	n = int(input())
	l = set(map(int, input().split()))
	if len(l) == 1 and n != 1:
		print(-1)
		return
	l1 = []
	m = min(l)
	for i in l:
		l1.append(i - m)
	ans = 0
	for i in l1:
		ans = gcd(ans, i)
	print(ans)
t = int(input())
for _ in range(t):
	solve()


import math
t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	if all((a[0] == i for i in a)):
		print(-1)
		continue
	smallest = min(a)
	for i in range(n):
		a[i] = smallest - a[i]
	best_gcd = math.gcd(a[0], a[1])
	for i in range(2, n):
		best_gcd = math.gcd(best_gcd, a[i])
	print(best_gcd)


t = int(input())
while t:
	t -= 1
	n = int(input())
	l = list(map(int, input().split()))

	def gcd(x, y):
		while y:
			(x, y) = (y, x % y)
		return x
	a = set()
	mini = min(l)
	for i in range(n):
		if l[i] != mini:
			a.add(l[i] - mini)
	if len(a) == 0:
		print(-1)
	elif len(a) == 1:
		for i in a:
			print(i)
	else:
		s = list(a)
		g = gcd(s[0], s[1])
		for i in range(2, len(s)):
			g = gcd(g, s[i])
		print(g)


from math import gcd
t = int(input())
for _ in range(t):
	input()
	arr = list(map(int, input().split()))
	tmp = arr[0]
	ok = True
	for i in arr:
		if i != tmp:
			ok = False
	if ok:
		print(-1)
		continue
	gcdd = 0
	for i in range(0, len(arr)):
		for j in range(0, len(arr)):
			if i == j:
				continue
			gcdd = gcd(gcdd, arr[i] - arr[j])
	print(gcdd)


from math import gcd as g
t = int(input())
while t != 0:
	n = int(input())
	a = list(map(int, input().split()))[:n]
	if len(set(a)) == 1:
		print(-1)
		t -= 1
		continue
	mini = min(a)
	net = []
	for i in a:
		if i != mini:
			net.append(abs(mini - i))
	ans = net[0]
	for j in net:
		ans = g(ans, j)
	print(ans)
	t -= 1


def find_gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
for _ in range(int(input())):
	n = int(input())
	arr = []
	b = [int(x) for x in input().split()]
	d = sorted(b)
	for i in range(len(d) - 1):
		if d[i] == d[i + 1]:
			pass
		else:
			diff = d[i + 1] - d[i]
			arr.append(diff)
	if len(arr) < 1:
		print(-1)
	elif len(arr) == 1:
		print(arr[0])
	elif len(arr) == 2:
		print(find_gcd(arr[0], arr[1]))
	elif len(arr) > 2:
		gcd = find_gcd(arr[0], arr[1])
		for i in range(2, len(arr)):
			gcd = find_gcd(gcd, arr[i])
		print(gcd)


T = int(input())

def gcd(a, b):
	if a < b:
		return gcd(b, a)
	while b > 0:
		t = a
		a = b
		b = t % b
	return a
for t in range(T):
	ans = 0
	N = int(input())
	A = list(map(int, input().split()))
	A.sort()
	if A[0] == A[N - 1]:
		print(-1)
		continue
	B = [A[i] - A[0] for i in range(1, N)]
	k = B[0]
	for i in range(1, N - 1):
		k = gcd(k, B[i])
	print(k)


def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
for i in range(int(input())):
	n = int(input())
	l = [int(x) for x in input().split()]
	l1 = [0] * (n - 1)
	for i in range(1, len(l)):
		l1[i - 1] = l[i] - l[0]
	l1.sort()
	ans = 0
	bo = True
	for i in range(len(l1)):
		ans = gcd(ans, l1[i])
	if ans == 0:
		bo = False
	if bo:
		print(abs(ans))
	else:
		print(-1)


def pgcd(a, b):
	if b == 0:
		return a
	else:
		r = a % b
		return pgcd(b, r)
t = int(input())
for i in range(t):
	n = int(input())
	result = list(map(int, input().split()))
	res = []
	for j in range(len(result) - 1):
		res.append(abs(result[j] - result[j - 1]))
	a = res[0]
	p = a
	for j in range(len(res)):
		a = res[j]
		p = pgcd(p, a)
	if p == 0:
		p = -1
	print(p)


import sys
t = int(input())

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	m = max(a)
	d = [m - a[i] for i in range(n) if m - a[i] != 0]
	if len(d) == 0:
		print(-1)
	elif len(d) == 1:
		print(d[0])
	else:
		minn = min(d)
		s = 0
		while True:
			if d[s] != 0:
				fir = d[s]
				s += 1
				break
			s += 1
		while True:
			if d[s] != 0:
				sec = d[s]
				s += 1
				break
			s += 1
		g = gcd(fir, sec)
		for i in range(s, len(d)):
			g = gcd(g, d[i])
		print(g)


def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	if len(set(a)) == 1:
		print(-1)
		continue
	k = min(a)
	m = max(a)
	for i in range(n):
		if a[i] == k:
			a[i] = m - k
		else:
			a[i] -= k
	res = a[0]
	for c in a[1:]:
		res = gcd(res, c)
	print(1 if res == 0 else res)


import math
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	if len(list(set(a))) == 1:
		print(-1)
		continue
	arr = []
	for i in range(n):
		for j in range(n):
			arr.append(abs(a[i] - a[j]))
	m = arr[0]
	for i in range(1, len(arr)):
		m = math.gcd(m, arr[i])
	print(m)


def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)
t = int(input())
for x in range(t):
	n = int(input())
	karr = [int(x) for x in input().split()]
	karr = set(karr)
	karr = [x for x in karr]
	karr.sort()
	if len(karr) == 1:
		print(-1)
		continue
	mindiff = 0
	for i in range(1, len(karr)):
		mindiff = gcd(karr[i] - karr[i - 1], mindiff)
	print(mindiff)


def gcd(a, b):
	while True:
		c = a % b
		if c == 0:
			break
		a = b
		b = c
	return b
t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	result = []
	for j in range(1, n):
		if l[j] != l[j - 1]:
			result.append(l[j] - l[j - 1])
	if len(result) == 0:
		print(-1)
		continue
	if len(result) == 1:
		print(result[0])
		continue
	k = gcd(result[0], result[1])
	for j in range(2, len(result)):
		k = gcd(k, result[j])
	print(k)


import math
test = int(input())
for i in range(test):
	n = int(input())
	ar = input().split()
	ar = [int(ele) for ele in ar]
	arr = []
	for ele in ar:
		if ele not in arr:
			arr.append(ele)
	if len(arr) == 1:
		print(-1)
		continue
	arr.sort()
	ar = []
	for j in range(1, len(arr)):
		ar.append(arr[j] - arr[j - 1])
	if len(ar) > 1:
		gd = math.gcd(ar[0], ar[1])
		for j in range(2, len(ar)):
			if gd > math.gcd(ar[j], ar[j - 1]):
				gd = math.gcd(ar[j], ar[j - 1])
		print(gd)
	else:
		print(ar[0])


def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, str(input()).split()))
	a.sort()
	pre = a[0]
	ans = 0
	for i in range(1, n):
		if a[i] == pre:
			continue
		b = a[i] - pre
		ans = gcd(ans, b)
		if ans == 1:
			break
	if ans == 0:
		ans = -1
	print(ans)


t = int(input())

def hcf(x, y):
	if x < y:
		tem = y
		y = x
		x = tem
	if x % y == 0:
		return y
	return hcf(y, x % y)
while t:
	n = int(input())
	s = list(map(int, input().split()))
	s = list(set(s))
	minn = min(s)
	if len(s) == 1:
		print(-1)
		t -= 1
		continue
	s.remove(minn)
	s = [i - minn for i in s]
	a = s[0]
	for i in range(1, len(s)):
		a = hcf(a, s[i])
	print(a)
	t -= 1


def gcd(a, b):
	while a != 0:
		(a, b) = (b % a, a)
	return b
t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	m = min(a)
	for k in range(n):
		a[k] -= m
	ans = gcd(a[0], a[1])
	for j in range(n - 2):
		ans = gcd(ans, a[j + 2])
	if ans == 0:
		ans = -1
	print(ans)


import math
t = int(input())
for i in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	b = min(A)
	i = 0
	k = A[i] - b
	while i < n:
		if A[i] != b:
			y = math.gcd(k, A[i] - b)
			k = y
		i += 1
	if k >= 1:
		print(k)
	else:
		print('-1')


def all_are_same(nums):
	nums = list(set(nums))
	if len(nums) == 1:
		return -1
	nums.sort()
	diff = set()

	def find_gcd(x, y):
		if x == 0:
			return y
		return find_gcd(y % x, x)
	for i in range(len(nums) - 1):
		diff.add(nums[i + 1] - nums[i])
	diff = list(diff)
	result = diff[0]
	for i in range(1, len(diff)):
		result = find_gcd(result, diff[i])
	return result
N = int(input())
for _ in range(N):
	n = int(input())
	nums = [int(x) for x in input().split()]
	print(all_are_same(nums))


def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)
for _ in range(int(input())):
	m = int(input())
	list1 = list(map(int, input().split()))
	list1.sort()
	if list1[0] == list1[-1]:
		print(-1)
	else:
		gcds = 0
		for i in range(1, len(list1)):
			gcds = gcd(gcds, list1[i] - list1[i - 1])
		print(gcds)


from math import gcd
t = int(input())
for _ in range(t):
	n = int(input())
	data = [int(i) for i in str(input()).split()]
	minsim = min(data)
	prev = minsim
	is_equal = True
	for num in data:
		if num != minsim:
			is_equal = False
	if is_equal:
		print('-1')
	else:
		ans = 0
		data = sorted(data)
		for i in range(n):
			ans = gcd(ans, data[i] - minsim)
		print(ans)


def gcd(x, y):
	if x % y == 0:
		return y
	return gcd(y, x % y)
for i in range(int(input())):
	n = int(input())
	arr = list(set((int(x) for x in input().split())))
	length = len(arr)
	if length == 1:
		print(-1)
		continue
	diff = []
	for j in range(length - 1):
		diff.append(abs(arr[j] - arr[j + 1]))
	if len(diff) == 1:
		print(diff[0])
		continue
	gcdd = gcd(diff[0], diff[1])
	for j in range(length - 1):
		gcdd = gcd(gcdd, diff[j])
	print(gcdd)


from math import gcd
t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	m = min(a)
	l = []
	for j in range(n):
		l.append(a[j] - m)
	x = l[0]
	for k in l:
		x = gcd(x, k)
	if x == 0:
		print(-1)
	else:
		print(x)


def find_gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().strip().split()))[:n]
	a.sort()
	d = []
	for x in range(n):
		for y in range(n):
			if a[x] < a[y]:
				d.append(a[y] - a[x])
				break
	if sum(a) / n == a[0]:
		d.append(0)
		d.append(0)
	d.sort()
	if len(d) == 1:
		d.append(d[0])
	gcd = find_gcd(d[0], d[1])
	for i in range(2, len(d)):
		gcd = find_gcd(gcd, d[i])
	if gcd == 0:
		print(-1)
	else:
		print(gcd)


from math import gcd
in1 = int(input())
for i in range(in1):
	in2 = int(input())
	in3 = input().split()
	in3 = list(map(int, in3))
	mi = min(in3)
	in3 = list([x - mi for x in in3])
	g = 0
	a = set(in3)
	if len(a) != 1:
		for j in in3:
			if j != 0:
				if g == 0:
					g = j
				g = gcd(g, j)
		print(g)
	else:
		print(-1)


import math
cases = int(input())
for case in range(cases):
	n = int(input())
	nums = list(map(lambda x: int(x), input().split(' ')))
	lcmSet = set()
	for i in range(len(nums)):
		for j in range(i + 1, len(nums)):
			if nums[i] != nums[j]:
				lcmSet.add(abs(nums[j] - nums[i]))
	lcmList = list(lcmSet)
	computed = 0
	if len(lcmList) == 0:
		print(-1)
		computed = 1
	elif len(lcmList) == 1:
		print(lcmList[0])
		computed = 1
	if not computed:
		res = math.gcd(lcmList[0], lcmList[1])
		for i in range(2, len(lcmList)):
			res = math.gcd(res, lcmList[i])
		print(res)


from math import gcd
from functools import reduce
x = int(input(''))
for i in range(x):
	x1 = input('')
	a = list(map(int, input().split(' ')))
	a.sort()
	list1 = []
	lcm = 1
	same = True
	for i in range(len(a)):
		if a[i] - a[0] > 0:
			same = False
			list1.append(a[i] - a[0])
	if same == True:
		print(-1)
	else:
		lcm = reduce(gcd, list1)
		print(lcm)


def find_gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
for _ in range(int(input())):
	n = int(input())
	arr = sorted(list(map(int, input().split())))
	m = arr[0]
	for i in range(n):
		arr[i] = arr[i] - m
	gcd = find_gcd(arr[0], arr[1])
	for i in range(2, n):
		gcd = find_gcd(gcd, arr[i])
	print(gcd if gcd > 0 else -1)


def hcf(a, b):
	if b == 0:
		return a
	return hcf(b, a % b)
t = int(input())
for _ in range(t):
	n = int(input())
	list1 = list(map(int, input().strip().split()))
	list1.sort()
	if list1[0] == list1[n - 1]:
		print(-1)
		continue
	ans = list1[1] - list1[0]
	for i in range(2, n):
		ans = hcf(ans, list1[i] - list1[i - 1])
	print(ans)


def gcd(a, b):
	if b == 0:
		return a
	if b > a:
		return gcd(b, a)
	return gcd(b, a % b)

def gcdList(n, l):
	i = 0
	gcdi = l[i]
	while i < n - 1:
		if gcdi == 1:
			return gcdi
		else:
			gcdi = gcd(gcdi, l[i + 1])
		i += 1
	return gcdi
t = int(input())
final = []
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	differences = []
	for x in range(n):
		for y in range(x + 1, n):
			differences.append(abs(l[x] - l[y]))
	ans = gcdList(n, differences)
	if ans == 0:
		final.append(-1)
	else:
		final.append(ans)
for _ in range(t):
	print(final[_])


import math
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	if a[0] == a[n - 1]:
		print(-1)
	else:
		dif = 0
		for i in range(1, len(a)):
			dif = math.gcd(dif, a[i] - a[i - 1])
		print(dif)


from math import gcd

def mgc(n, arr):
	mini = min(arr)
	temp = []
	for i in arr:
		if i != mini:
			temp.append(i - mini)
	if len(temp) == 0:
		return -1
	ans = temp[0]
	for i in temp[1:]:
		ans = gcd(ans, i)
	return ans
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	print(mgc(n, arr))


def gcd(a, b):
	if a == b:
		return a
	elif a > b:
		(a, b) = (b, a)
	while a > 0:
		(a, b) = (b % a, a)
	return b
for _ in range(int(input())):
	n = int(input())
	temp = list(map(int, input().split()))
	xd = min(temp)
	x = []
	for i in range(n):
		if temp[i] > xd:
			x += [temp[i] - xd]
	if len(x) == 1:
		print(x[0])
	elif len(x) == 0:
		print(-1)
	else:
		g = gcd(x[0], x[1])
		for i in range(2, len(x)):
			g = gcd(g, x[i])
			if g == 1:
				break
		print(g)


def nod(a, b):
	while b != 0:
		c = a % b
		a = b
		b = c
	return a
t = int(input())
for tt in range(t):
	n = int(input())
	a = []
	aa = [int(x) for x in input().split()]
	aa.sort()
	tmp = aa[0]
	for i in aa:
		if i != aa[0]:
			a.append(i - aa[0])
	if len(a) == 0:
		print('-1')
	else:
		res = a[0]
		for i in a:
			res = nod(res, i)
		print(res)


import math
t = int(input())
for tc in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	mn = min(a)
	gc = 0
	for x in a:
		gc = math.gcd(gc, x - mn)
	if gc == 0:
		gc = -1
	print(gc)