import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

import heapq

ans = 0
heapq.heapify(a)
while a:
    t = heapq.heappop(a)
    if ans == 0:
        ans = t
        continue
    else:
        big = max(ans, t)
        small = min(ans, t)
        if big % small != 0:
            ans = big % small
            heapq.heappush(a, small)

print(ans) import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline sys.setrecursionlimit(10 ** 7) sys.setrecursionlimit sys setrecursionlimit 10 ** 7 10 7 n = int(input()) n int(input()) int input() input a = list(map(int, input().split())) a list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split import heapq heapq ans = 0 ans 0 heapq.heapify(a) heapq.heapify heapq heapify a while a:
    t = heapq.heappop(a)
    if ans == 0:
        ans = t
        continue
    else:
        big = max(ans, t)
        small = min(ans, t)
        if big % small != 0:
            ans = big % small
            heapq.heappush(a, small) a t = heapq.heappop(a) t heapq.heappop(a) heapq.heappop heapq heappop a if ans == 0:
        ans = t
        continue
    else:
        big = max(ans, t)
        small = min(ans, t)
        if big % small != 0:
            ans = big % small
            heapq.heappush(a, small) ans == 0 ans 0 ans = t ans t continue big = max(ans, t) big max(ans, t) max ans t small = min(ans, t) small min(ans, t) min ans t if big % small != 0:
            ans = big % small
            heapq.heappush(a, small) big % small != 0 big % small big small 0 ans = big % small ans big % small big small heapq.heappush(a, small) heapq.heappush heapq heappush a small print(ans) print ans n = int(input()) int(input()) n t = heapq.heappop(a) heapq.heappop(a) t small = min(ans, t) min(ans, t) small input = sys.stdin.readline sys.stdin.readline input ans = t t ans big = max(ans, t) max(ans, t) big a = list(map(int, input().split())) list(map(int, input().split())) a ans = 0 0 ans ans = big % small big % small ans
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

import heapq

ans = 0
heapq.heapify(a)
while a:
    t = heapq.heappop(a)
    if ans == 0:
        ans = t
        continue
    else:
        big = max(ans, t)
        small = min(ans, t)
        if big % small != 0:
            ans = big % small
            heapq.heappush(a, small)

print(ans)
