#priority_queueで管理

#普通にソートすればいいじゃん

n=int(eval(input()))

a=sorted([int(i) for i in input().split()])

#print(a)

while len(a)!=1:

    b=a[0]

    for i in range(1,n):

        a[i]-=b*(a[i]//b)

    a=sorted([i for i in a if i!=0])

    n=len(a)

    #print(a)



print((a[0]))

n=int(eval(input()))

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

while len(a)>1:

    l=len(a)

    a.sort()

    b=[a[0] if i==0 else a[i]%a[0] for i in range(l)]

    a=[b[i] for i in range(l) if b[i]!=0]

print((a[0]))

# priority_queueで管理
# 普通にソートすればいいじゃん
n = int(eval(input()))
a = sorted([int(i) for i in input().split()])
# print(a)
while len(a) != 1:
    b = a[0]
    for i in range(1, n):
        a[i] -= b * (a[i] // b)
    a = sorted([i for i in a if i != 0])
    n = len(a)
    # print(a)
print((a[0]))

n = int(eval(input()))
a = list(map(int, input().split()))
while len(a) > 1:
    l = len(a)
    a.sort()
    b = [a[0] if i == 0 else a[i] % a[0] for i in range(l)]
    a = [b[i] for i in range(l) if b[i] != 0]
print((a[0]))

-# priority_queueで管理 -# 普通にソートすればいいじゃん -a = sorted([int(i) for i in input().split()]) -# print(a) -while len(a) != 1: -    b = a[0] -    for i in range(1, n): -        a[i] -= b * (a[i] // b) -    a = sorted([i for i in a if i != 0]) -    n = len(a) -    # print(a) +a = list(map(int, input().split())) +while len(a) > 1: +    l = len(a) +    a.sort() +    b = [a[0] if i == 0 else a[i] % a[0] for i in range(l)] +    a = [b[i] for i in range(l) if b[i] != 0]