Read problems statements in Mandarin Chinese  and Russian. 

Rupsa recently started to intern under Chef. He gave her N type of ingredients of varying quantity  A_{1}, A_{2}, ..., A_{N} respectively to store it. But as she is lazy to arrange them she puts them all in a storage box.

Chef comes up with a new recipe and decides to prepare it. He asks Rupsa to get two units of each type ingredient for the dish. But when she went to retrieve the ingredients, she realizes that she can only pick one item at a time from the box and can know its type only after she has picked it out. The picked item is not put back in the bag.

She, being lazy, wants to know the maximum number of times she would need to pick items from the box in the worst case so that it is guaranteed that she gets at least two units of each type of ingredient. If it is impossible to pick items in such a way, print -1.

------ Input ------ 

The first line of the input contains an integer T denoting the number of test cases.		
The first line of each test case contains a single integer N denoting the number of different type of ingredients.
The second line contains N space-separated integers A_{1}, A_{2}, ..., A_{N} denoting the quantity of each ingredient.
 
------ Output ------ 

For each test case, output a single line containing an integer denoting the answer corresponding to that test case.

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

$1 ≤ T ≤ 10$
$1 ≤ N ≤ 10^{5}$
$1 ≤ A_{i} ≤ 10^{4}$

------ Sub tasks ------ 

$Subtask #1: 1 ≤ N ≤ 1000 (30 points)$
$Subtask #2: original constraints (70 points)$

----- Sample Input 1 ------ 
2

2

2 2

1

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

2
----- explanation 1 ------ 

In Example 1, she need to pick up all items.
In Example 2, since there is only one type of ingredient, picking two items is enough.

Difficulty: EASY

Solutions:
for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	ans = 0
	for i in a:
		if i < 2:
			print(-1)
			ans = 1
			break
	if ans == 1:
		continue
	s = sum(a)
	m = min(a)
	s -= m
	s += 2
	print(s)


for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	if min(a) <= 1:
		print(-1)
	else:
		print(sum(a) - min(a) + 2)


def snek(l, n):
	(s, m) = (0, 100000000.0)
	for j in l:
		s += j
		m = min(m, j)
	if m == 1:
		print(-1)
	else:
		print(s - m + 2)
t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	snek(l, n)


t = int(input())
for p in range(t):
	n = int(input())
	inp = input()
	l = [int(x) for x in inp.split()]
	if 1 in l:
		print(-1)
	else:
		print(sum(l) - min(l) + 2)


t = int(input())
for i in range(0, t):
	n = int(input())
	a = list(map(int, input().strip().split()))
	z = min(a)
	if z < 2:
		print(-1)
	else:
		print(sum(a) - min(a) + 2)


t = int(input())
for _ in range(0, t):
	input()
	l = list(map(int, input().split()))
	l.sort()
	l.reverse()
	su = 0
	f = 0
	for i in range(len(l)):
		if l[i] < 2:
			f = 1
			break
		else:
			su = su + l[i]
	if f == 1:
		print('-1')
	else:
		print(su - min(l) + 2)


tests = int(input())
for i in range(tests):
	length = int(input())
	arr = list(map(int, input().split()))
	minimum = min(arr)
	if minimum < 2:
		print(-1)
	else:
		print(sum(arr) - minimum + 2)


def solve(A, N):
	(sum, minn) = (0, 100000)
	for i in A:
		sum += i
		minn = min(minn, i)
	if minn == 1:
		print(-1)
	else:
		print(sum - minn + 2)
T = int(input())
for _ in range(T):
	N = int(input())
	A = list(map(int, input().split()))
	solve(A, N)


T = int(input().strip())
for _ in range(T):
	N = int(input().strip())
	items = list(map(int, input().strip().split()))
	if 1 in items:
		print(-1)
	else:
		a = min(items)
		picks = sum(items) - a + 2
		print(picks)


t = int(input())
while t:
	n = int(input())
	flag = 0
	arr = [int(x) for x in input().split()]
	arr.sort()
	sum = 0
	for i in arr:
		if i < 2:
			flag = 1
			break
		sum = sum + i
	sum = sum + 2 - arr[0]
	if flag == 1:
		print('-1')
	else:
		print(sum)
	t = t - 1


for tc in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	mina = min(a)
	if mina == 1:
		ans = -1
	else:
		ans = sum(a) - (mina - 2)
	print(ans)


for i in range(int(input())):
	N = int(input())
	l = list(map(int, input().split()))
	if 1 in l:
		print(-1)
	else:
		x = sum(l) - min(l) + 2
		print(x)


t = int(input())
for tc in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	s = sum(arr)
	m = min(arr)
	if m == 1:
		print(-1)
	else:
		print(s - m + 2)


t = int(input())
while t:
	t = t - 1
	n = int(input())
	arr = list(map(int, input().split(' ')))
	total = sum(arr)
	if min(arr) < 2:
		print('-1')
	else:
		print(total - min(arr) + 2)


t = int(input())
for ni in range(t):
	n = int(input())
	l = [int(i) for i in input().split()]
	if 1 in l:
		print(-1)
	else:
		m = min(l)
		print(sum(l) - m + 2)


t = int(input())
while t > 0:
	n = int(input())
	l = list(map(int, input().split()))
	s = 0
	q = 0
	m = min(l)
	for i in l:
		if i < 2:
			print(-1)
			q = 1
			break
		s += i
	if q == 0:
		s -= m
		s += 2
		print(s)
	t -= 1


class Solution(object):

	def __init__(self):
		for _ in range(int(input())):
			self.get_input()
			self.solve()
			self.print_ans()
	pass

	def get_input(self):
		self.n = int(input())
		self.a = list(map(int, input().split()))
		pass

	def solve(self):
		self.ans = -1
		if len(self.a) == 1:
			if self.a[0] >= 2:
				self.ans = 2
			else:
				self.ans = -1
			return
		if self.a.count(1):
			return
		self.ans = sum(self.a) - min(self.a) + 2
		pass

	def print_ans(self):
		print(self.ans)
		pass
Solution()


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	f = 0
	for i in a:
		if i < 2:
			f = 1
			break
	if f == 1:
		print(-1)
		continue
	print(sum(a) - (min(a) - 2))


for _ in range(int(input())):
	n = int(input())
	li = list(map(int, input().split()))
	if min(li) < 2:
		print(-1)
		continue
	else:
		print(sum(li) - (min(li) - 2))


for _ in range(int(input())):
	n = int(input())
	items = list(map(int, input().split()))
	if min(items) < 2:
		total = -1
	else:
		total = sum(items) - min(items) + 2
	print(total)


for _ in range(int(input())):
	n = int(input())
	l = [int(i) for i in input().split()]
	if 1 in l:
		print(-1)
	elif min(l) == 2:
		print(sum(l))
	else:
		print(sum(l) - min(l) + 2)