from heapq import heapify, heappush, heappop

N = int(eval(input()))

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

heapify(Alist)

while len(Alist)>1:

    Alist = [a for a in Alist if a > 0]

    min_num = heappop(Alist)

    for i in range(len(Alist)):

        Alist[i] %= min_num

    heappush(Alist, min_num)

print((Alist[0]))
from heapq import heapify, heappop, heappush

N = int(eval(input()))

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

heapify(Alist)

while len(Alist) > 1:

    atk = heappop(Alist)

    Alist = [A % atk for A in Alist if (A % atk != 0)]

    heapify(Alist)

    heappush(Alist, atk)

print((Alist[0]))

from heapq import heapify, heappush, heappop

N = int(eval(input()))
Alist = list(map(int, input().split()))
heapify(Alist)
while len(Alist) > 1:
    Alist = [a for a in Alist if a > 0]
    min_num = heappop(Alist)
    for i in range(len(Alist)):
        Alist[i] %= min_num
    heappush(Alist, min_num)
print((Alist[0]))

from heapq import heapify, heappop, heappush

N = int(eval(input()))
Alist = list(map(int, input().split()))
heapify(Alist)
while len(Alist) > 1:
    atk = heappop(Alist)
    Alist = [A % atk for A in Alist if (A % atk != 0)]
    heapify(Alist)
    heappush(Alist, atk)
print((Alist[0]))

-from heapq import heapify, heappush, heappop +from heapq import heapify, heappop, heappush -    Alist = [a for a in Alist if a > 0] -    min_num = heappop(Alist) -    for i in range(len(Alist)): -        Alist[i] %= min_num -    heappush(Alist, min_num) +    atk = heappop(Alist) +    Alist = [A % atk for A in Alist if (A % atk != 0)] +    heapify(Alist) +    heappush(Alist, atk)