def main():
    N = int(input())
    A = [int(a) for a in input().split()]
    mon1 = [a for a in A]
    mon2 = [a for a in A]

    for i in range(10**9):
        mon1 = sorted(mon2)
        mon2 = list()

        for j in range(1, len(mon1)):
            m_ = mon1[j] % mon1[0]
            if m_ != 0:
                mon2.append(m_)

        mon2.append(mon1[0])

        if len(mon2) == 1:
            break

    print(mon2[0])
    
if __name__ == "__main__":
    main() def main():
    N = int(input())
    A = [int(a) for a in input().split()]
    mon1 = [a for a in A]
    mon2 = [a for a in A]

    for i in range(10**9):
        mon1 = sorted(mon2)
        mon2 = list()

        for j in range(1, len(mon1)):
            m_ = mon1[j] % mon1[0]
            if m_ != 0:
                mon2.append(m_)

        mon2.append(mon1[0])

        if len(mon2) == 1:
            break

    print(mon2[0])
     main N = int(input()) N int(input()) int input() input int(a) for a in input().split() for a in input().split() a input().split() ().split () input split for a in input().split() int(a) int a A = [int(a) for a in input().split()] A [int(a) for a in input().split()] a for a in A for a in A a A for a in A a mon1 = [a for a in A] mon1 [a for a in A] a for a in A for a in A a A for a in A a mon2 = [a for a in A] mon2 [a for a in A] for i in range(10**9):
        mon1 = sorted(mon2)
        mon2 = list()

        for j in range(1, len(mon1)):
            m_ = mon1[j] % mon1[0]
            if m_ != 0:
                mon2.append(m_)

        mon2.append(mon1[0])

        if len(mon2) == 1:
            break

     i range(10**9) range 10**9 10 9 mon1 = sorted(mon2) mon1 sorted(mon2) sorted mon2 mon2 = list() mon2 list() list for j in range(1, len(mon1)):
            m_ = mon1[j] % mon1[0]
            if m_ != 0:
                mon2.append(m_)

         j range(1, len(mon1)) range 1 len(mon1) len mon1 m_ = mon1[j] % mon1[0] m_ mon1[j] % mon1[0] mon1[j] mon1 j mon1[0] mon1 0 if m_ != 0:
                mon2.append(m_)

         m_ != 0 m_ 0 mon2.append(m_) mon2.append mon2 append m_ mon2.append(mon1[0]) mon2.append mon2 append mon1[0] mon1 0 if len(mon2) == 1:
            break

     len(mon2) == 1 len(mon2) len mon2 1 break print(mon2[0]) print mon2[0] mon2 0 if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    N = int(input())
    A = [int(a) for a in input().split()]
    mon1 = [a for a in A]
    mon2 = [a for a in A]

    for i in range(10**9):
        mon1 = sorted(mon2)
        mon2 = list()

        for j in range(1, len(mon1)):
            m_ = mon1[j] % mon1[0]
            if m_ != 0:
                mon2.append(m_)

        mon2.append(mon1[0])

        if len(mon2) == 1:
            break

    print(mon2[0])
     def main():
    N = int(input())
    A = [int(a) for a in input().split()]
    mon1 = [a for a in A]
    mon2 = [a for a in A]

    for i in range(10**9):
        mon1 = sorted(mon2)
        mon2 = list()

        for j in range(1, len(mon1)):
            m_ = mon1[j] % mon1[0]
            if m_ != 0:
                mon2.append(m_)

        mon2.append(mon1[0])

        if len(mon2) == 1:
            break

    print(mon2[0])
     main
def main():
    N = int(input())
    A = [int(a) for a in input().split()]
    mon1 = [a for a in A]
    mon2 = [a for a in A]

    for i in range(10**9):
        mon1 = sorted(mon2)
        mon2 = list()

        for j in range(1, len(mon1)):
            m_ = mon1[j] % mon1[0]
            if m_ != 0:
                mon2.append(m_)

        mon2.append(mon1[0])

        if len(mon2) == 1:
            break

    print(mon2[0])
    
if __name__ == "__main__":
    main()