def vs(A):

    A = sorted(A)

    pA = list([x % A[0] for x in A])

    pA[0] = A[0]

    return list([x for x in pA if x != 0])





N = int(eval(input()))

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





spA = -1

sA = -2

while spA != sA:

    sA = sum(A)

    pA = vs(A)

    spA = sum(pA)

    A = pA



print((sum(A)))

import sys



readline = sys.stdin.buffer.readline





def sss(A, N):

    A.sort()

    while A[0] == 0:

        A.remove(0)

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

        A[i] = A[i] % A[0]

    if A[0] == sum(A):

        print((sum(A)))

    else:

        return sss(A, N)





def main():

    N = int(readline())

    A = list(map(int, readline().split()))



    sss(A, N)





main()

def vs(A):
    A = sorted(A)
    pA = list([x % A[0] for x in A])
    pA[0] = A[0]
    return list([x for x in pA if x != 0])


N = int(eval(input()))
A = list(map(int, input().split()))
spA = -1
sA = -2
while spA != sA:
    sA = sum(A)
    pA = vs(A)
    spA = sum(pA)
    A = pA
print((sum(A)))

import sys

readline = sys.stdin.buffer.readline


def sss(A, N):
    A.sort()
    while A[0] == 0:
        A.remove(0)
    for i in range(1, len(A)):
        A[i] = A[i] % A[0]
    if A[0] == sum(A):
        print((sum(A)))
    else:
        return sss(A, N)


def main():
    N = int(readline())
    A = list(map(int, readline().split()))
    sss(A, N)


main()

-def vs(A): -    A = sorted(A) -    pA = list([x % A[0] for x in A]) -    pA[0] = A[0] -    return list([x for x in pA if x != 0]) +import sys + +readline = sys.stdin.buffer.readline -N = int(eval(input())) -A = list(map(int, input().split())) -spA = -1 -sA = -2 -while spA != sA: -    sA = sum(A) -    pA = vs(A) -    spA = sum(pA) -    A = pA -print((sum(A))) +def sss(A, N): +    A.sort() +    while A[0] == 0: +        A.remove(0) +    for i in range(1, len(A)): +        A[i] = A[i] % A[0] +    if A[0] == sum(A): +        print((sum(A))) +    else: +        return sss(A, N) + + +def main(): +    N = int(readline()) +    A = list(map(int, readline().split())) +    sss(A, N) + + +main()