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: interview

Starter code:

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)
 else:
  if not d:
   print(a[0] * n)
  else:
   d = sorted(d)
   print(n * d[0])

import fractions
for i in range(eval(input())):
 n,z=eval(input()),list(map(int,input().split()))
 q=z[0]
 for __ in range(1,n): q=fractions.gcd(q,z[__])
 print(q*n)


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)

'''
Created on 22-Nov-2015

@author: root1
'''

from fractions import gcd


def read_int():
 return int(input())


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


def __gcd(lst):
 result = 0
 for num in lst:
  result = gcd(result, num)
 return result


def main():
 tc = read_int()
 for _ in range(tc):
  n = read_int()
  print(n * __gcd(read_int_list()))

def __starting_point():
 main()

__starting_point()

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 fractions import gcd as G
for ii in range(eval(input())):
 n=eval(input())
 arr=list(map(int,input().split()))
 k=arr[0]
 for i in range(1,n-1):
  k=G(k,arr[i])
 print(k*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 fractions import gcd
from functools import reduce
a=eval(input())
while(a):

 x=eval(input())
 b=list(map(int,input().split()))
 print(reduce(gcd,(b))*x)
 
  


 a-=1


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

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)


from fractions import gcd
from functools import reduce

t = int(input())
for tt in range(t):
 n = int(input())
 arr = list(map(int, input().split()))
 g = reduce(lambda x,y: gcd(x,y), arr)
 print(g * n)


from fractions import gcd
t = eval(input())
for _ in range(t):
 n = eval(input())
 a = [int(x) for x in input().strip().split()]
 s = a[0]
 for i in range(1,n):
  s = gcd(s,a[i])
 print(s*n)

from fractions import gcd

for t in range(eval(input())):
  n = eval(input())
  ans = 0
  for x in map( int, input().split() ):
    ans = gcd( ans, x )
  print(ans*n)