n=int(eval(input()))

a_s=list(map(int,input().split()))



def sakujo(a_list):

    for i in range(len(a_list)):

        if a_list[i]!=0:

            end=i

            break

    return a_list[i:]



while True:

    a_s.sort()

    a_s=sakujo(a_s)

    if len(a_s)==1:

        break

    for i in range(1,len(a_s)):

        a_s[i]=a_s[i]%a_s[0]



print((sum(a_s)))

from fractions import gcd

n=int(eval(input()))

a_s=list(map(int,input().split()))

a=a_s[0]

for i in range(n):

    ans=gcd(a,a_s[i])

    a=ans

print(ans)

n = int(eval(input()))
a_s = list(map(int, input().split()))


def sakujo(a_list):
    for i in range(len(a_list)):
        if a_list[i] != 0:
            end = i
            break
    return a_list[i:]


while True:
    a_s.sort()
    a_s = sakujo(a_s)
    if len(a_s) == 1:
        break
    for i in range(1, len(a_s)):
        a_s[i] = a_s[i] % a_s[0]
print((sum(a_s)))

from fractions import gcd

n = int(eval(input()))
a_s = list(map(int, input().split()))
a = a_s[0]
for i in range(n):
    ans = gcd(a, a_s[i])
    a = ans
print(ans)

+from fractions import gcd + - - -def sakujo(a_list): -    for i in range(len(a_list)): -        if a_list[i] != 0: -            end = i -            break -    return a_list[i:] - - -while True: -    a_s.sort() -    a_s = sakujo(a_s) -    if len(a_s) == 1: -        break -    for i in range(1, len(a_s)): -        a_s[i] = a_s[i] % a_s[0] -print((sum(a_s))) +a = a_s[0] +for i in range(n): +    ans = gcd(a, a_s[i]) +    a = ans +print(ans)