import sys


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def get_min_without_0(A):
    A = [a for a in A if a != 0]
    return min(A)


def attack(A):
    a = get_min_without_0(A)
    A.remove(a)
    return list(map(lambda x: x % a, A)) + [a]


def check(A):
    cnt = 0
    for a in A:
        if a == 0:
            cnt += 1
    if cnt == len(A) - 1:
        return False
    else:
        return True


def main():
    n = ni()
    A = nl()

    while check(A):
        A = attack(A)
    print(max(A))


if __name__ == '__main__':
    main() import sys sys stdin = sys.stdin stdin sys.stdin sys stdin def ns(): return stdin.readline().rstrip() ns def ni(): return int(stdin.readline().rstrip()) ni def nm(): return map(int, stdin.readline().split()) nm def nl(): return list(map(int, stdin.readline().split())) nl def get_min_without_0(A):
    A = [a for a in A if a != 0]
    return min(A) get_min_without_0 a for a in A if a != 0 for a in A if a != 0 a A a != 0 a 0 if a != 0 a A = [a for a in A if a != 0] A [a for a in A if a != 0] return min(A) min(A) min A A A def attack(A):
    a = get_min_without_0(A)
    A.remove(a)
    return list(map(lambda x: x % a, A)) + [a] attack a = get_min_without_0(A) a get_min_without_0(A) get_min_without_0 A A.remove(a) A.remove A remove a return list(map(lambda x: x % a, A)) + [a] list(map(lambda x: x % a, A)) + [a] list(map(lambda x: x % a, A)) list map(lambda x: x % a, A) map lambda x: x % a x % a x a x A [a] a A A def check(A):
    cnt = 0
    for a in A:
        if a == 0:
            cnt += 1
    if cnt == len(A) - 1:
        return False
    else:
        return True check cnt = 0 cnt 0 for a in A:
        if a == 0:
            cnt += 1
     a A if a == 0:
            cnt += 1
     a == 0 a 0 cnt += 1 cnt 1 if cnt == len(A) - 1:
        return False
    else:
        return True cnt == len(A) - 1 cnt len(A) - 1 len(A) len A 1 return False False return True True A A def main():
    n = ni()
    A = nl()

    while check(A):
        A = attack(A)
    print(max(A)) main n = ni() n ni() ni A = nl() A nl() nl while check(A):
        A = attack(A)
     check(A) check A A = attack(A) A attack(A) attack A print(max(A)) print max(A) max A if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def nl(): return list(map(int, stdin.readline().split())) def nl(): return list(map(int, stdin.readline().split())) nl def get_min_without_0(A):
    A = [a for a in A if a != 0]
    return min(A) def get_min_without_0(A):
    A = [a for a in A if a != 0]
    return min(A) get_min_without_0 def attack(A):
    a = get_min_without_0(A)
    A.remove(a)
    return list(map(lambda x: x % a, A)) + [a] def attack(A):
    a = get_min_without_0(A)
    A.remove(a)
    return list(map(lambda x: x % a, A)) + [a] attack stdin = sys.stdin sys.stdin stdin def ni(): return int(stdin.readline().rstrip()) def ni(): return int(stdin.readline().rstrip()) ni def nm(): return map(int, stdin.readline().split()) def nm(): return map(int, stdin.readline().split()) nm def main():
    n = ni()
    A = nl()

    while check(A):
        A = attack(A)
    print(max(A)) def main():
    n = ni()
    A = nl()

    while check(A):
        A = attack(A)
    print(max(A)) main def ns(): return stdin.readline().rstrip() def ns(): return stdin.readline().rstrip() ns def check(A):
    cnt = 0
    for a in A:
        if a == 0:
            cnt += 1
    if cnt == len(A) - 1:
        return False
    else:
        return True def check(A):
    cnt = 0
    for a in A:
        if a == 0:
            cnt += 1
    if cnt == len(A) - 1:
        return False
    else:
        return True check
import sys


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def get_min_without_0(A):
    A = [a for a in A if a != 0]
    return min(A)


def attack(A):
    a = get_min_without_0(A)
    A.remove(a)
    return list(map(lambda x: x % a, A)) + [a]


def check(A):
    cnt = 0
    for a in A:
        if a == 0:
            cnt += 1
    if cnt == len(A) - 1:
        return False
    else:
        return True


def main():
    n = ni()
    A = nl()

    while check(A):
        A = attack(A)
    print(max(A))


if __name__ == '__main__':
    main()
