Chef gives an array A with N elements to Babla. Babla's task is to find the maximum non-negative integer X such that:

No element in the array belongs to the range [-X, X]. In other words, for all (1≤ i ≤ N), either A_{i} < -X or A_{i} > X.

Help Babla to find the maximum non-negative integer X for which the given condition is satisfied or determine if no such X exists.

------ Input Format ------ 

- The first line of input will contain a single integer T, denoting the number of test cases.
- Each test case consists of multiple lines of input.
- The first line of each test case contains an integer N — the number of elements in the array.
- The second line of each test case contains N space-separated integers A_{1}, A_{2}, \ldots, A_{N} representing the array A.

------ Output Format ------ 

For each test case, output on a new line, the maximum non-negative integer X, satisfying the above condition.  
If no such X exists, output -1 instead.

------ Constraints ------ 

$1 ≤ T ≤ 10^{5}$
$1 ≤ N ≤ 10^{5}$
$-10^{9} ≤ A_{i} ≤ 10^{9}$
- Sum of $N$ over all test cases does not exceed $2 \cdot 10^{5}$.

----- Sample Input 1 ------ 
3
5
8 4 2 5 2
6
7 9 -10 8 12 17
4
0 -3 -1 -10

----- Sample Output 1 ------ 
1
6
-1

----- explanation 1 ------ 
Test case $1$: The maximum value of $X$ such that no element of the array belongs to the range $[-X, X]$ is $1$. All elements of the array are strictly greater than $1$.

Test case $2$: The maximum value of $X$ such that no element of the array belongs to the range $[-X, X]$ is $6$. All positive elements of the array are strictly greater than $6$ and negative elements are strictly less than $-6$.

Test case $3$: It is not possible to choose an element $X$ that satisfies the given condition.

Difficulty: EASY

Solutions:
t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	k = abs(l[0])
	for i in range(n):
		if abs(l[i]) < k:
			k = abs(l[i])
	if k == 0:
		print(-1)
	else:
		print(k - 1)


t = int(input())
for _ in range(t):
	n = int(input())
	l = [abs(int(x)) for x in input().split()]
	if min(l) == 0:
		print(-1)
	else:
		print(min(l) - 1)


t = int(input())
for ni in range(t):
	n = int(input())
	l = [int(i) for i in input().split()]
	(pos, neg) = (1000000000, -1000000000)
	for i in l:
		if i >= 0:
			pos = min(pos, i)
		else:
			neg = max(neg, i)
	print(min(abs(neg), pos) - 1)


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	for i in range(n):
		l[i] = abs(l[i])
	l.sort()
	if l[0] == 0:
		print(-1)
	else:
		print(l[0] - 1)


T = int(input())
for i in range(T):
	n = int(input())
	l = sorted(list(map(int, input().split())))
	m = []
	for i in range(n):
		if abs(l[i]) != l[i]:
			l[i] = abs(l[i])
	if 0 in l:
		print(-1)
	else:
		print(min(l) - 1)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = []
	for i in a:
		b.append(abs(i))
	b.sort()
	if b[0] == 0:
		print(-1)
	else:
		print(b[0] - 1)


for _ in range(int(input())):
	n = input()
	a = [abs(int(x)) for x in input().split()]
	print(min(a) - 1)


for x in range(int(input())):
	y = int(input())
	my_list = list(map(int, input().split()))
	for element in range(y):
		my_list[element] = abs(my_list[element])
	my_list.sort()
	if my_list[0] == 0:
		print(-1)
	else:
		print(my_list[0] - 1)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	li = []
	for i in arr:
		li.append(abs(i))
	li.sort()
	if 0 in li:
		print(-1)
	else:
		print(li[0] - 1)


t = int(input())
for i in range(t):
	n = int(input())
	arr_A = input().split(' ')
	for j in range(n):
		arr_A[j] = abs(int(arr_A[j]))
	arr_A.sort()
	if arr_A[0] - 1 < 0:
		print(-1)
	else:
		print(arr_A[0] - 1)


t = int(input())
for i in range(t):
	n = int(input())
	arr = [abs(int(n)) for n in input().split()]
	arr.sort()
	if arr[0] >= 0:
		print(arr[0] - 1)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	pos = []
	neg = []
	ans = 0
	for i in range(n):
		if a[i] < 0:
			neg.append(-a[i])
		else:
			pos.append(a[i])
	if len(pos) == 0:
		ans = min(neg)
	elif len(neg) == 0:
		ans = min(pos)
	else:
		ans = min(min(pos), min(neg))
	if ans <= 0:
		print(-1)
	else:
		print(ans - 1)


from functools import reduce
import math

def vout(v):
	return ' '.join(map(str, v))

def vin(datatype):
	return list(map(datatype, input().split()))

def main(is_testCases=True):
	testCases = 1
	if is_testCases:
		testCases = int(input())
	for _ in range(testCases):
		n = int(input())
		v = vin(int)
		v += [float('inf'), float('-inf')]
		v1 = list(filter(lambda a: a >= 0, v))
		v2 = list(filter(lambda a: a < 0, v))
		(c1, c2) = (min(v1) - 1, -max(v2) - 1)
		print(min(c1, c2))
main()


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	l = []
	for i in a:
		l.append(abs(i))
	print(min(l) - 1)


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	small = max(arr)
	flag = 0
	mini = 1000000007
	maxi = -1000000007
	for i in range(len(arr)):
		if arr[i] >= 0:
			mini = min(mini, arr[i] - 1)
		else:
			maxi = max(maxi, arr[i] + 1)
	print(min(-maxi, mini))


for i in range(int(input())):
	m = int(input())
	l = list(map(int, input().split()))
	for j in range(len(l)):
		l[j] = abs(l[j])
	l.sort()
	if l[0] != 0:
		print(l[0] - 1)
	else:
		print(-1)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	for i in range(n):
		a[i] = abs(a[i])
	b = sorted(a)
	if b[0] == 0:
		print(-1)
	else:
		print(b[0] - 1)


t = int(input())
for t in range(t):
	n = int(input())
	arr = [abs(int(i)) for i in input().split()]
	arr = sorted(arr)
	if arr[0] == 0:
		print(-1)
	else:
		print(arr[0] - 1)


x = int(input())
for i in range(x):
	l2 = []
	y = int(input())
	l = list(map(int, input().split()))
	for k in l:
		l2.append(abs(k))
	m = min(l2)
	if m == 0:
		print(-1)
		continue
	else:
		print(m - 1)


def makepositive(a):
	a = int(a)
	if a < 0:
		return -a
	else:
		return a
n = int(input())
for i in range(n):
	inp = input()
	array = [*map(makepositive, input().split())]
	minnum = min(array)
	if minnum == 0:
		print(-1)
	else:
		print(minnum - 1)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a = [abs(i) for i in a]
	if min(a) == 0:
		print(-1)
	else:
		print(min(a) - 1)


def given_fn():
	for _ in range(int(input())):
		lenn = input()
		preslst = [int(er) for er in input().split(' ')]
		if 0 in preslst:
			print(-1)
		else:
			pres1lst = [abs(ew) for ew in preslst]
			print(min(pres1lst) - 1)
given_fn()


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	z = [abs(i) for i in l]
	z = sorted(z)
	if z[0] == 0:
		print(-1)
	else:
		print(z[0] - 1)


for i in range(int(input())):
	n = int(input())
	lst = list(map(int, input().split()))[:n]
	lst1 = []
	for i in lst:
		lst1.append(abs(i))
	if min(lst1) == 0:
		print(-1)
	else:
		print(min(lst1) - 1)


AmzX = 0
NnN = int(input())
while NnN:
	NnN -= 1
	NnN1 = int(input())
	AmzXx = [int(x) for x in input().split()]
	for i in range(NnN1):
		AmzXx[i] = abs(AmzXx[i])
	AmzXx.sort()
	if AmzXx[0] == 0:
		print(-1)
	else:
		print(AmzXx[0] - 1)


n = int(input())
while n:
	n -= 1
	N = int(input())
	l = [int(x) for x in input().split()]
	for i in range(N):
		l[i] = abs(l[i])
	l.sort()
	if l[0] == 0:
		print(-1)
	else:
		print(l[0] - 1)


n = int(input())
for i in range(n):
	z = int(input())
	s = list(map(int, input().split()))
	s.sort()
	mini = abs(max(s))
	for j in s:
		mini = min(mini, abs(j))
	if mini == 0:
		print(-1)
	else:
		print(mini - 1)


for i in range(int(input())):
	num = int(input())
	lis = list(map(int, input().split(' ')))
	lis.sort()
	mini = 10 ** 9
	for j in lis:
		mini = min(mini, abs(j))
	if mini == 0:
		print(-1)
	else:
		print(mini - 1)


testcases = int(input())
while testcases > 0:
	N = int(input())
	li = list(map(int, input().split()))[:N]
	for i in range(N):
		li[i] = abs(li[i])
	li.sort()
	if li[0] == 0:
		print(-1)
	else:
		print(li[0] - 1)
	testcases -= 1


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	min_value = 1000000000
	for i in range(n):
		l[i] = abs(l[i])
		min_value = min(l[i], min_value)
	print(min_value - 1)


import heapq
import operator
import itertools
import sys
import functools
import bisect
import math
import random
import statistics
from collections import Counter
RTM1 = 1000000000.0 + 7
RTM2 = 998244353

def fact(n):
	if n == 1 or n == 0:
		return 1
	return n * fact(n - 1)

def prod(a, b):
	if a == 0 or b == 0:
		return 0
	return a + prod(a, b - 1)
for _ in range(int(input())):
	ravi = int(input())
	teja = [abs(int(x)) for x in input().split()]
	teja.sort()
	if teja[0] == 0:
		print(-1)
	else:
		print(teja[0] - 1)


import sys
for _ in range(int(input())):
	n = int(input())
	lis = list(map(int, input().split()))
	min = sys.maxsize
	for ele in lis:
		if abs(ele) <= min:
			min = abs(ele) - 1
	print(min)


t = int(input())
for i in range(t):
	n = int(input())
	L = sorted(list(map(int, input().split())))
	x = lambda y: abs(y)
	L1 = []
	for item in L:
		L1.append(x(item))
	L1.sort()
	print(L1[0] - 1)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()[:n]))
	least = min(a, key=lambda x: abs(x))
	amin = [abs(x) for x in a]
	if min(amin) == 0:
		print(-1)
	else:
		print(min(amin) - 1)


import math

def main():
	t = int(input())
	while t:
		solve()
		t -= 1

def solve():
	n = int(input())
	arr = [int(num) for num in input().split(' ')]
	pos = [num for num in arr if num >= 0]
	neg = [abs(num) for num in arr if num < 0]
	res = min(min(pos) if len(pos) else math.inf, min(neg) if len(neg) else math.inf)
	print(res - 1)
main()


def makePositive(num):
	if int(num) > 0:
		return int(num)
	else:
		return int(num) * -1
for i in range(int(input())):
	n = int(input())
	array = list(map(makePositive, input().split()))
	if min(array) == 0:
		print(-1)
	else:
		print(min(array) - 1)


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	m = []
	x = max(l)
	y = min(l)
	for i in range(0, n):
		m.append(abs(l[i]))
	print(min(m) - 1)


T = int(input())
for i in range(T):
	N = int(input())
	B = list(map(int, input().split()))
	A = []
	for j in B:
		A.append(abs(j))
	C = A.copy()
	m = min(A)
	if m == 0:
		print(-1)
	else:
		print(m - 1)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	x = []
	for i in range(n):
		x.append(abs(a[i]))
	x.sort()
	print(x[0] - 1)


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	theva = abs(l[0])
	for j in range(n):
		theva = min(theva, abs(l[j]))
	print(theva - 1)


for i in range(int(input())):
	input()
	b = list(map(int, input().split()))
	b = list(map(abs, b))
	if min(b) < 1:
		print(-1)
	else:
		print(min(b) - 1)


t = int(input())
while t > 0:
	n = int(input())
	l = [int(x) for x in input().split()]
	if 0 in l:
		print(-1)
	elif max(l) > 0 and min(l) > 0:
		print(min(l) - 1)
	elif max(l) < 0 and min(l) < 0:
		print(abs(max(l) + 1))
	else:
		gl = [x for x in l if x > 0]
		ll = [x for x in l if x < 0]
		if min(gl) <= abs(max(ll)):
			print(min(gl) - 1)
		else:
			print(abs(max(ll)) - 1)
	t -= 1


for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	if 0 in a:
		print(-1)
	else:
		p = [int(x) for x in a if x > 0]
		n = [int(x) for x in a if x < 0]
		if p == []:
			mn = max(n)
			print(-mn - 1)
		elif n == []:
			mp = min(p)
			print(mp - 1)
		else:
			mn = max(n)
			mp = min(p)
			print(min(mp - 1, -mn - 1))


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l1 = list(map(lambda x: abs(x), l))
	print(min(l1) - 1)


t = int(input())
while t != 0:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	b = []
	c = 0
	for i in a:
		b.append(abs(i))
	new = min(b)
	if new == 0:
		print(-1)
	else:
		new -= 1
		a = sorted(a)
		for i in a:
			if i in range(-new, new + 1):
				c = 1
				break
		if c == 1:
			print(-1)
		else:
			print(new)


t = int(input())
for i in range(1, t + 1):
	n = int(input())
	list1 = list(map(int, input().split()[:n]))
	for j in range(n):
		list1[j] = abs(list1[j])
	list1.sort()
	if list1[0] == 0:
		print('-1')
	else:
		print(list1[0] - 1)


t = int(input())
for i in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	l = []
	for i in A:
		l.append(abs(i))
	l.sort()
	print(l[0] - 1)


T = int(input())
for _ in range(T):
	n = int(input())
	a = list(map(int, input().split()))
	if 0 in a:
		print(-1)
	else:
		b = [abs(e) for e in a]
		b.sort()
		print(b[0] - 1)


for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	if 0 in a:
		print(-1)
	else:
		m = 10 ** 9
		n = -10 ** 9
		for x in a:
			if x > 0:
				m = min(m, x)
			else:
				n = max(n, x)
		print(min(m, -n) - 1)


for i in range(0, int(input())):
	n = int(input())
	b = sorted(list(map(int, input().split())))
	if b[n - 1] < 0:
		print(abs(b[n - 1]) - 1)
	elif b[n - 1] == 0:
		print(-1)
	else:
		for j in range(0, n):
			if b[j] < 0:
				continue
			elif b[j] == 0:
				print(-1)
				break
			else:
				if j == 0:
					print(b[j] - 1)
				else:
					print(min(abs(b[j - 1]), b[j]) - 1)
				break


for i in range(int(input())):
	t = int(input())
	a = list(map(int, input().split()))
	for i in range(t):
		a[i] = abs(a[i])
	a.sort()
	if a[i] == 0:
		print('-1')
	else:
		print(a[0] - 1)


t = int(input())
for _ in range(t):
	n = int(input())
	a1 = list(map(int, input().split()))
	for i in range(len(a1)):
		if a1[i] < 0:
			a1[i] = -a1[i]
	k = a1.index(min(a1))
	if a1[k] - 1 == -1:
		print('-1')
	else:
		print(a1[k] - 1)


t = int(input())
ls = []
for i in range(t):
	n = int(input())
	ls = input().split()
	for j in range(n):
		ls[j] = int(ls[j])
		if ls[j] < 0:
			ls[j] = -ls[j]
	ls.sort()
	print(ls[0] - 1)


t = int(input())
for i in range(t):
	n = int(input())
	lst = list(map(int, input().split()))
	ans = []
	for i in lst:
		i = abs(i)
		ans.append(i)
	print(min(ans) - 1)


t = int(input())
while t:
	n = input()
	arr = list(map(int, input().split()))
	arr.sort()
	zero_found = 0
	max_neg = float('-infinity')
	min_pos = float('infinity')
	for i in arr:
		if i == 0:
			zero_found = 1
			break
		elif i > 0 and i < min_pos:
			min_pos = i
		elif i < 0 and i > max_neg:
			max_neg = i
	if zero_found:
		print(-1)
	else:
		num = min(abs(max_neg), abs(min_pos)) - 1
		if max_neg < -num and min_pos > num:
			print(num)
		else:
			print(-1)
	t -= 1


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	(maxn, minp) = (-1000000000, 1000000000)
	z = 0
	for i in range(n):
		if a[i] > 0:
			minp = min(minp, a[i])
		elif a[i] < 0:
			maxn = max(maxn, a[i])
		else:
			z = 1
	if z == 1:
		print(-1)
	else:
		m = min(abs(maxn), minp)
		print(m - 1)


test_cases = int(input())
for i in range(test_cases):
	n = int(input())
	array = list(map(int, input().split()))[:n]
	num = abs(array[0])
	flag = 0
	for i in array:
		if i == 0:
			flag = 1
			break
		elif abs(i) < num:
			num = abs(i)
	if flag == 1:
		print('-1')
	else:
		print(num - 1)


for i in range(int(input())):
	n = int(input())
	b = list(map(int, input().split()))
	min = abs(b[0])
	for j in b:
		j = abs(j)
		if j < min:
			min = j
	if min == 0:
		print('-1')
	else:
		print(min - 1)


import sys

def solve(n, l):
	pos_min = sys.maxsize
	for i in l:
		if i == 0:
			return -1
		pos_min = min(pos_min, abs(i))
	return pos_min - 1
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	print(solve(n, l))


t = int(input())
ans = []
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	print(min(map(abs, a)) - 1)


x = int(input())
for _ in range(x):
	n = int(input())
	a = list(map(int, input().split()))
	al = []
	flag = 0
	for i in range(n):
		al.append(abs(a[i]))
	mina = min(al)
	if mina == 0:
		print(-1)
	else:
		print(mina - 1)