def main():

    n = int(eval(input()))

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

    m = min(a)

    next_m = m

    count = 0

    while count != n:

        m = next_m

        count = 0

        pre = a[0]

        for i in range(n):

            if a[i] == pre:

                count += 1

            a[i] %= m

            if a[i] != 0:

                next_m = min(next_m, a[i])

            else:

                a[i] = m

            pre = a[i]

    print(m)

    

if __name__ == '__main__':

    main()
from fractions import gcd





def main():

    n = int(eval(input()))

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

    ans = a[0]

    for aa in a:

        ans = gcd(ans, aa)

        

    print(ans)

    

    

if __name__ == '__main__':

    main()
def main():
    n = int(eval(input()))
    a = list(map(int, input().split()))
    m = min(a)
    next_m = m
    count = 0
    while count != n:
        m = next_m
        count = 0
        pre = a[0]
        for i in range(n):
            if a[i] == pre:
                count += 1
            a[i] %= m
            if a[i] != 0:
                next_m = min(next_m, a[i])
            else:
                a[i] = m
            pre = a[i]
    print(m)


if __name__ == "__main__":
    main()

from fractions import gcd


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


if __name__ == "__main__":
    main()

+from fractions import gcd + + -    m = min(a) -    next_m = m -    count = 0 -    while count != n: -        m = next_m -        count = 0 -        pre = a[0] -        for i in range(n): -            if a[i] == pre: -                count += 1 -            a[i] %= m -            if a[i] != 0: -                next_m = min(next_m, a[i]) -            else: -                a[i] = m -            pre = a[i] -    print(m) +    ans = a[0] +    for aa in a: +        ans = gcd(ans, aa) +    print(ans)