from heapq import heapify, heappush, heappop

n = int(eval(input()))

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

heapify(A)

while len(A) != 1:

    t = heappop(A)

    A = [a % t for a in A if a % t != 0]

    if A is None:

        A = [t]

        break

    heappush(A, t)

print((A[0]))

from fractions import gcd

n = int(eval(input()))

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

ans = A[0]

for a in A[1:]:

    ans = gcd(ans, a)

print(ans)

from heapq import heapify, heappush, heappop

n = int(eval(input()))
A = list(map(int, input().split()))
heapify(A)
while len(A) != 1:
    t = heappop(A)
    A = [a % t for a in A if a % t != 0]
    if A is None:
        A = [t]
        break
    heappush(A, t)
print((A[0]))

from fractions import gcd

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

-from heapq import heapify, heappush, heappop +from fractions import gcd -heapify(A) -while len(A) != 1: -    t = heappop(A) -    A = [a % t for a in A if a % t != 0] -    if A is None: -        A = [t] -        break -    heappush(A, t) -print((A[0])) +ans = A[0] +for a in A[1:]: +    ans = gcd(ans, a) +print(ans)