Sereja has an array A of N positive integers : A[1], A[2], A[3], ... , A[N]. 

In a single operation on the array, he performs the following two steps :  

- Pick two indices i, j s.t. A[i] > A[j]
- A[i] -= A[j]

Sereja can apply these operations any number of times (possibly zero), such that the sum of resulting elements of the array is as small as possible.

Help Sereja find this minimum sum.

-----Input-----

First line of input contains an integer T - the number of test cases. T test cases follow.

First line of each test case contains the integer N. The next line contains N integers — A[1], A[2], A[3], ... , A[N].

-----Output-----
For each test case, output a single line with the answer.

-----Constraints-----
- 1 ≤ T ≤ 10
- 1 ≤ N ≤ 105
- 1 ≤ A[i] ≤ 109

-----Example-----
Input:
2
1
1
3
2 4 6

Output:
1
6

-----Explanation-----
Example case 2. In this case, one possible way in which Sereja can perform the operations could be as follows. 

-  Pick i = 2, j = 1. A[2] -= A[1]. Now the resulting array would be [2, 2, 6].
-  Pick i = 3, j = 2. A[3] -= A[2]. Now the resulting array would be [2, 2, 4].
-  Pick i = 3, j = 2. A[3] -= A[2]. Now the resulting array would be [2, 2, 2]. 

As the resulting array is [2 2 2], so the sum is 6.

Difficulty: UNKNOWN_DIFFICULTY

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

def main():
	t = int(input())
	while t != 0:
		t = t - 1
		n = int(input())
		if n == 1:
			print(input())
		else:
			a = list(map(int, input().split(' ')))
			p = a[0]
			for i in range(1, n):
				p = gcd(p, a[i])
				if p == 1:
					break
			print(n * p)

def __starting_point():
	main()
__starting_point()


for i in range(int(input())):
	n = int(input())
	a = sorted([int(i) for i in input().split()])
	m = False
	d = []
	for i in range(1, n):
		if a[i] - a[i - 1] != 0:
			d.append(a[i] - a[i - 1])
		if a[i] - a[i - 1] != 0 and a[0] % (a[i] - a[i - 1]) != 0:
			m = True
			break
	if m:
		print(n)
	elif not d:
		print(a[0] * n)
	else:
		d = sorted(d)
		print(n * d[0])


t = eval(input())
while t != 0:
	t -= 1
	n = eval(input())
	a = list(map(int, input().split()))
	a = sorted(a)
	diff = a[0]
	for i in range(1, n):
		if a[i] - a[i - 1] < diff and a[i] - a[i - 1] > 0:
			diff = a[i] - a[i - 1]
	print(diff * n)


from fractions import *
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	q = a[0]
	for i in range(1, n):
		q = gcd(a[i], q)
		if q == 1:
			break
	print(q * n)


import math
from functools import reduce

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a

def GCD(list):
	return reduce(gcd, list)
for _ in range(eval(input())):
	n = eval(input())
	s = list(map(int, input().split()))
	ans = GCD(s)
	print(ans * n)


from functools import reduce

def GCD(a, b):
	a = abs(a)
	b = abs(b)
	while a:
		(a, b) = (b % a, a)
	return b

def GCD_List(list):
	return reduce(GCD, list)
a = eval(input())
while a:
	x = eval(input())
	b = list(map(int, input().split()))
	print(GCD_List(b) * x)
	a -= 1


def gcd(a, b):
	if a == 0:
		return b
	if b == 0:
		return a
	if a > b:
		return gcd(a % b, b)
	else:
		return gcd(a, b % a)
for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	g = a[0]
	for i in range(1, n):
		g = gcd(a[i], g)
		if g == 1:
			break
	print(g * n)


from math import ceil
for i in range(eval(input())):
	n = eval(input())
	arr = list(map(int, input().split()))
	while max(arr) != min(arr):
		arr.sort()
		mini = float(arr[0])
		for i in range(n):
			fac = int(ceil(arr[i] / mini)) - 1
			arr[i] -= mini * fac
	print(int(sum(arr)))


t = eval(input())
for _ in range(t):
	n = eval(input())
	num = [int(i) for i in input().split()]
	num.sort()
	ans = num[0]
	for i in range(1, n):
		if num[i] != num[i - 1]:
			ans = min(ans, num[i] - num[i - 1])
	print(ans * n)