import sys
import heapq

input = sys.stdin.readline


def main():
    N = int(input())
    A = list(map(int, input().split()))
    heapq.heapify(A)
    while True:
        m1 = heapq.heappop(A)
        try:
            m2 = heapq.heappop(A)
        except IndexError:
            print(m1)
            break
        m2 %= m1
        heapq.heappush(A, m1)
        if m2 > 0:
            heapq.heappush(A, m2)


if __name__ == '__main__':
    main() import sys sys import heapq heapq input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline def main():
    N = int(input())
    A = list(map(int, input().split()))
    heapq.heapify(A)
    while True:
        m1 = heapq.heappop(A)
        try:
            m2 = heapq.heappop(A)
        except IndexError:
            print(m1)
            break
        m2 %= m1
        heapq.heappush(A, m1)
        if m2 > 0:
            heapq.heappush(A, m2) main 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 heapq.heapify(A) heapq.heapify heapq heapify A while True:
        m1 = heapq.heappop(A)
        try:
            m2 = heapq.heappop(A)
        except IndexError:
            print(m1)
            break
        m2 %= m1
        heapq.heappush(A, m1)
        if m2 > 0:
            heapq.heappush(A, m2) True m1 = heapq.heappop(A) m1 heapq.heappop(A) heapq.heappop heapq heappop A try:
            m2 = heapq.heappop(A)
        except IndexError:
            print(m1)
            break
         except IndexError:
            print(m1)
            break
         print(m1) print m1 break m2 = heapq.heappop(A) m2 heapq.heappop(A) heapq.heappop heapq heappop A m2 %= m1 m2 m1 heapq.heappush(A, m1) heapq.heappush heapq heappush A m1 if m2 > 0:
            heapq.heappush(A, m2) m2 > 0 m2 0 heapq.heappush(A, m2) heapq.heappush heapq heappush A m2 if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    N = int(input())
    A = list(map(int, input().split()))
    heapq.heapify(A)
    while True:
        m1 = heapq.heappop(A)
        try:
            m2 = heapq.heappop(A)
        except IndexError:
            print(m1)
            break
        m2 %= m1
        heapq.heappush(A, m1)
        if m2 > 0:
            heapq.heappush(A, m2) def main():
    N = int(input())
    A = list(map(int, input().split()))
    heapq.heapify(A)
    while True:
        m1 = heapq.heappop(A)
        try:
            m2 = heapq.heappop(A)
        except IndexError:
            print(m1)
            break
        m2 %= m1
        heapq.heappush(A, m1)
        if m2 > 0:
            heapq.heappush(A, m2) main input = sys.stdin.readline sys.stdin.readline input
import sys
import heapq

input = sys.stdin.readline


def main():
    N = int(input())
    A = list(map(int, input().split()))
    heapq.heapify(A)
    while True:
        m1 = heapq.heappop(A)
        try:
            m2 = heapq.heappop(A)
        except IndexError:
            print(m1)
            break
        m2 %= m1
        heapq.heappush(A, m1)
        if m2 > 0:
            heapq.heappush(A, m2)


if __name__ == '__main__':
    main()
