import sys
import copy
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():
    N = in_n()
    A = sorted(in_nl())

    while True:
        B = []
        B.append(A[0])
        for i in range(1, len(A)):
            x = A[i] % A[0]
            if x:
                B.append(x)

        if len(B) == 1:
            break
        else:
            B.sort()
            A = copy.copy(B)

    print(B[0])


if __name__ == '__main__':
    main() import sys sys import copy copy read = sys.stdin.buffer.read read sys.stdin.buffer.read sys.stdin.buffer sys.stdin sys stdin buffer read readline = sys.stdin.buffer.readline readline sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline in_n = lambda: int(readline()) in_n lambda: int(readline()) int(readline()) int readline() readline in_nn = lambda: map(int, readline().split()) in_nn lambda: map(int, readline().split()) map(int, readline().split()) map int readline().split() ().split () readline split in_nl = lambda: list(map(int, readline().split())) in_nl lambda: list(map(int, readline().split())) list(map(int, readline().split())) list map(int, readline().split()) map int readline().split() ().split () readline split in_na = lambda: map(int, read().split()) in_na lambda: map(int, read().split()) map(int, read().split()) map int read().split() ().split () read split in_s = lambda: readline().rstrip().decode('utf-8') in_s lambda: readline().rstrip().decode('utf-8') readline().rstrip().decode('utf-8') ().rstrip().decode ().rstrip() ().rstrip () readline rstrip decode 'utf-8' def main():
    N = in_n()
    A = sorted(in_nl())

    while True:
        B = []
        B.append(A[0])
        for i in range(1, len(A)):
            x = A[i] % A[0]
            if x:
                B.append(x)

        if len(B) == 1:
            break
        else:
            B.sort()
            A = copy.copy(B)

    print(B[0]) main N = in_n() N in_n() in_n A = sorted(in_nl()) A sorted(in_nl()) sorted in_nl() in_nl while True:
        B = []
        B.append(A[0])
        for i in range(1, len(A)):
            x = A[i] % A[0]
            if x:
                B.append(x)

        if len(B) == 1:
            break
        else:
            B.sort()
            A = copy.copy(B)

     True B = [] B [] B.append(A[0]) B.append B append A[0] A 0 for i in range(1, len(A)):
            x = A[i] % A[0]
            if x:
                B.append(x)

         i range(1, len(A)) range 1 len(A) len A x = A[i] % A[0] x A[i] % A[0] A[i] A i A[0] A 0 if x:
                B.append(x)

         x B.append(x) B.append B append x if len(B) == 1:
            break
        else:
            B.sort()
            A = copy.copy(B)

     len(B) == 1 len(B) len B 1 break B.sort() B.sort B sort A = copy.copy(B) A copy.copy(B) copy.copy copy copy B print(B[0]) print B[0] B 0 if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main readline = sys.stdin.buffer.readline sys.stdin.buffer.readline readline in_nl = lambda: list(map(int, readline().split())) lambda: list(map(int, readline().split())) in_nl in_nn = lambda: map(int, readline().split()) lambda: map(int, readline().split()) in_nn in_na = lambda: map(int, read().split()) lambda: map(int, read().split()) in_na in_s = lambda: readline().rstrip().decode('utf-8') lambda: readline().rstrip().decode('utf-8') in_s in_n = lambda: int(readline()) lambda: int(readline()) in_n def main():
    N = in_n()
    A = sorted(in_nl())

    while True:
        B = []
        B.append(A[0])
        for i in range(1, len(A)):
            x = A[i] % A[0]
            if x:
                B.append(x)

        if len(B) == 1:
            break
        else:
            B.sort()
            A = copy.copy(B)

    print(B[0]) def main():
    N = in_n()
    A = sorted(in_nl())

    while True:
        B = []
        B.append(A[0])
        for i in range(1, len(A)):
            x = A[i] % A[0]
            if x:
                B.append(x)

        if len(B) == 1:
            break
        else:
            B.sort()
            A = copy.copy(B)

    print(B[0]) main read = sys.stdin.buffer.read sys.stdin.buffer.read read
import sys
import copy
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():
    N = in_n()
    A = sorted(in_nl())

    while True:
        B = []
        B.append(A[0])
        for i in range(1, len(A)):
            x = A[i] % A[0]
            if x:
                B.append(x)

        if len(B) == 1:
            break
        else:
            B.sort()
            A = copy.copy(B)

    print(B[0])


if __name__ == '__main__':
    main()
