CodeEff/ECCO huggingface dataset:
# Original solution

# import numpy as np
# import numpypy as np
import sys
import math
import string
import fractions
import re
import array
import copy
import functools

import collections
import itertools
import bisect
import heapq


from heapq import heappush
from heapq import heappop

# from itertools import accumulate
# from collections import deque
import random

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)


def main():
    n = int(eval(input()))
    l = list(map(int, input().split()))

    # eprint("=======================")
    while True:
        xx = min([x for x in l if x > 0])
        l = [(tt if tt==xx else tt%xx) for tt in l]

        # eprint(l)
        if all(x==l[0] for x in l):
            print(l[0])
            return 0
        if 1 in l:
            print(1)
            return 0
        if sum(l)==xx:
            print(xx)
            return 0
        # eprint("=======================")

    print(xx)
    return 0


if __name__ == '__main__':
    main()


# Optimized solution

# import numpy as np
# import numpypy as np
import sys
import math
import string
import fractions
import re
import array
import copy
import functools
import operator

import collections
import itertools
import bisect
import heapq


from heapq import heappush
from heapq import heappop

# from itertools import accumulate
# from collections import deque
import random

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)


def main():
    n = int(eval(input()))
    l = list(map(int, input().split()))

    eprint("=======================")
    while True:
        xx = min([x for x in l if x > 0])
        # eprint("min_index: "+str(min_index))
        eprint("xx: "+str(xx))
        flag = 0
        for i in range(len(l)):
            if l[i] == xx and flag == 0:
                flag=1
            else:
                l[i] = l[i]%xx

        # eprint(l)
        if all(x==l[0] for x in l):
            # eprint(l)
            print(l[0])
            return 0
        if 1 in l:
            print(1)
            return 0
        if sum(l)==xx:
            print(xx)
            return 0
        eprint("=======================")

    print(xx)
    return 0


if __name__ == '__main__':
    main()
# Original solution
n = int(eval(input()))
a = list(map(int,input().split()))
def f(a,b):
    if b==0:
        return a
    else:
        return f(b,a%b)
a = sorted(a)
ans = float('inf')
for i in range(len(a)-1):
    for j in range(i+1,len(a)):
        ans = min(ans,f(a[i],a[j]))
print(ans)

# Optimized solution
n = int(eval(input()))
a = list(map(int,input().split()))
memo = {}
def f(a,b):
    if b==0:
        return a
    else:
        return f(b,a%b)
a = sorted(a)
ans = float('inf')
for i in range(len(a)-1):
    ans = min(ans,f(a[i],a[i+1]))
print(ans)
# Original solution
N=int(eval(input()))
HP=list(map(int,input().split()))

a=HP[0]
b=HP[1]

(x, lastx) = (0, 1)
(y, lasty) = (1, 0)
while b != 0:
    q = a // b
    (a, b) = (b, a % b)
    (x, lastx) = (lastx - q * x, x)
    (y, lasty) = (lasty - q * y, y)
        
tmp=a

for i in range(1,N-1):
    a=tmp
    b=HP[i+1]
    
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
        
    tmp=a
    
print(tmp)

# Optimized solution
import sys

N=int(eval(input()))
HP=list(map(int,input().split()))

a=HP[0]
b=HP[1]

(x, lastx) = (0, 1)
(y, lasty) = (1, 0)
while b != 0:
    q = a // b
    (a, b) = (b, a % b)
    (x, lastx) = (lastx - q * x, x)
    (y, lasty) = (lasty - q * y, y)
        
tmp=a

for i in range(1,N-1):
    a=tmp
    b=HP[i+1]
    
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
        
    tmp=a
    if tmp==1:
        print(tmp)
        sys.exit()
    
print(tmp)
# Original solution
import bisect
import collections

n = int(eval(input()))
s = list(map(int,input().split()))

s.sort()

while len(s) > 1:#最も体力のあるのが攻撃を受ける
    temp = s.pop()
    for j in s:
        damege = (temp//j)*j
    if temp != 0 and temp != damege:
        index = bisect.bisect_left(s,temp-damege)
        s.insert(index,temp-damege)

print((s[0]))


# Optimized solution
import math

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

tmp = a[0]
for i in range(1,len(a)):
    tmp = math.gcd(tmp,a[i])
print(tmp)
# Original solution
from itertools import combinations

N=int(eval(input()))
A=[i for i in map(int,input().split())]

def gcd(x,y):
    while y!=0:
        x , y = y , x%y
    return x

ans=1e10
for comb in combinations(A,2):
    ans=min(ans,gcd(comb[0],comb[1]))
print(ans)

# Optimized solution
from itertools import combinations

N=int(eval(input()))
A=[i for i in map(int,input().split())]

def gcd(x,y):
    while y!=0:
        x , y = y , x%y
    return x

ans=A[0]
for i in range(1,len(A)):
    ans=min(ans,gcd(ans,A[i]))
print(ans)
# Original solution
n=int(eval(input()))
a_s=list(map(int,input().split()))
while True:
    a_s=set(a_s)
    a_s.discard(0)
    a_s=list(a_s)
    index=a_s.index(min(a_s))
    for i in range(len(a_s)):
        if i!=index and min(a_s)!=0:
            a_s[i]=a_s[i]%min(a_s)
    if len(a_s)==1:
        break
print((sum(a_s)))

# Optimized solution
n=int(eval(input()))
a_s=list(map(int,input().split()))

def sakujo(a_list):
    for i in range(len(a_list)):
        if a_list[i]!=0:
            end=i
            break
    return a_list[i:]

while True:
    a_s.sort()
    a_s=sakujo(a_s)
    if len(a_s)==1:
        break
    for i in range(1,len(a_s)):
        a_s[i]=a_s[i]%a_s[0]

print((sum(a_s)))
# Original solution
N = int(eval(input()))
A = list(map(int,input().split()))
ans = 0
for i in range(min(A),0,-1):
    if all( A[c] % i == 0 for c in range(N)):
        ans = i
        break   
print(ans)

# Optimized solution
N = int(eval(input()))
A = list(map(int,input().split()))
A = sorted(A) # とりあえず並び替えておく
tmp = 0
for i in range(N-1):
    while A[i]>0:
        tmp = A[i]
        A[i] = A[i+1] % A[i]
        A[i+1] = tmp
print((A[N-1]))
# Original solution
n = int(eval(input()))
A = list(map(int, input().split()))
A.sort()
while len(A) > 1:
  a = [A[0]]
  for i in range(1, len(A)):
    if A[i]%A[0] == 0: continue
    else: a.append(A[i]%A[0])
  A = sorted(a)
print((A[0]))

# Optimized solution
n = int(eval(input()))
A = sorted(list(map(int, input().split())))

while len(A) > 1:
    A = sorted([i%A[0] for i in A if i%A[0]!=0] + [A[0]])
print((A[0]))
# Original solution
n, *a = list(map(int, open(0).read().split()))
a.sort()
ans = 1e10
for i in range(1, n):
    x, y = a[0], a[i]
    while y%x:
        y -= y//x*x
        x, y = y, x
    ans = min(ans, x)
print(ans)

# Optimized solution
def gcd(a, b):
    if(a==0): return b
    if a<b: a,b=b,a
    while b: a,b=b,a%b
    return a

n, *a = list(map(int, open(0).read().split()))
g = 0
for i in a: g = gcd(g, i)
print(g)
# Original solution
n = int(eval(input()))
a = list(map(int,input().split()))
b = [0]*n
ans = min(a)
for j in range(min(a)):
	for i in range(n):
		b[i] = a[i]%ans
	if max(b) == 0:
		break
	else:
		ans = max(b)
print(ans)

# Optimized solution
n = int(eval(input()))
A = list(map(int,input().split()))

#ユーグリッドの互除法で、a,bを与えて、aをbで割ってあまりを計算する
#あまりがないときは、最後に割った数を返す（最大公約数）
#あまりがあるときは、bにあまりを入れて、再び計算する
def gcd(a,b):
	if b == 0:
		return a
	return gcd(b,a%b)


x = A[0]
for i in A[1:]:
	x = gcd(x,i)
print(x)
# Original solution
# 2019-11-12 15:53:47(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a

def main():
    n, *a = (int(x) for x in sys.stdin.read().split())
    
    ans = reduce(gcd, a)
    print(ans)



if __name__ == "__main__":
    main()


# Optimized solution
import sys
from functools import reduce

def gcd(a, b):
    while b:
        a, b = b, a % b
    return abs(a)
    
n, *a = list(map(int, sys.stdin.read().split()))

def main():
    return reduce(gcd, a)

if __name__ == '__main__':
    ans = main()
    print(ans)
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))

A.sort()

R = A[0]

while True:
    C = A.copy()
    B = [A[0]] + [A[i+1] - A[i] for i in range(len(A)-1) if A[i+1] > A[i]]
    B = list(set(B))
    B.sort()
    R = min(R, B[0])
    if C == B:
        break
    elif R == 1:
        break
    else:
        A = B

print(R)


# Optimized solution
N = int(eval(input()))
A = list(map(int, input().split()))

A.sort()

R = A[0]

while True:
    C = A.copy()
    B = [A[0]] + [a for a in [A[i+1] % A[i] for i in range(len(A)-1)] if a > 0]
    B = list(set(B))
    B.sort()
    R = min(R, B[0])
    if C == B:
        break
    elif R == 1:
        break
    else:
        A = B

print(R)
# Original solution
n=int(eval(input()))
a=list(map(int,input().split()))
import copy
for i in range(10**4):
  a.sort()
  wari=a[-2]
  if wari==0:
    print((a[-1]))
    break
  a[-1]=a[-1]%wari
  



# Optimized solution
n=int(eval(input()))
a=list(map(int,input().split()))

def gcd(a,b):
  aa=max(a,b)
  bb=min(a,b)
  cc=aa%bb
  return gcd(bb,cc) if cc else bb
  
p=gcd(a[0],a[1])
for i in range(2,n):
  p=gcd(p,a[i])
print(p)
# Original solution
# -*- coding: utf-8 -*-
import fractions

N = int(eval(input()))
A = list(map(int, input().split()))


def calc(monsters):
    if len(monsters) == 1:
        return monsters[0]

    min_monster = min(monsters)
    min_index = monsters.index(min_monster)
    new_monsters = []
    for i in range(len(monsters)):
        if i == min_index:
            new_monsters.append(monsters[i])

        remndr = monsters[i] % min_monster
        if remndr != 0:
            new_monsters.append(remndr)

    return calc(new_monsters)


ans = calc(A)
print(ans)

# Optimized solution
# -*- coding: utf-8 -*-

N = int(eval(input()))
A = list(map(int, input().split()))


def calc(monsters):
    if len(monsters) == 1:
        return monsters[0]

    min_monster = min(monsters)
    min_index = monsters.index(min_monster)
    new_monsters = []
    for i in range(len(monsters)):
        if i == min_index:
            new_monsters.append(monsters[i])

        remndr = monsters[i] % min_monster
        if remndr != 0:
            new_monsters.append(remndr)

    return calc(new_monsters)


ans = calc(A)
print(ans)
# Original solution
def gcd(a,b):
  if b==0:
    return a
  else:
    return gcd(b,a%b)

N=int(eval(input()))
A=list(map(int,input().split()))
g=A[0]

for i in range(1,N):
  g=gcd(g,A[i])

print(g)

# Optimized solution
N = int(eval(input()))
A = list(map(int, input().split()))

def gcd(x, y):
  while y:
    x, y = y, x % y
  return x

answer = A[0]
for i in range(1, N):
  answer = gcd(A[i], answer)
  
print(answer)
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))

def gcd(x, y):
  while y:
    x, y = y, x % y
  return x

answer = A[0]
for i in range(1, N):
  answer = gcd(A[i], answer)
  
print(answer)

# Optimized solution
import sys
input = sys.stdin.buffer.readline

N = int(eval(input()))
A = list(map(int, input().split()))

def gcd(x, y):
  while y:
    x, y = y, x % y
  return x

answer = A[0]
for i in range(1, N):
  answer = gcd(A[i], answer)
  
print(answer)
# Original solution
from collections import Counter


def factor(N):
    ret = []
    i = 2
    while N > 1:
        if N % i == 0:
            ret.append(i)
            N //= i
        else:
            i += 1
    return ret


def solve(N, As):
    iter = Counter(factor(min(As)))

    for a in As:
        for k, v in list(iter.items()):
            if a % k != 0:
                iter[k] = 0
            else:
                count = 0
                kk = k
                while a % kk == 0:
                    kk *= k
                    count += 1
                iter[k] = min(v, count)
    d = 1
    for k, v in list(iter.items()):
        if v != 0:
            d *= k ** v
    return d

if __name__ == "__main__":
    N = int(eval(input()))
    As = list(map(int, input().split(" ")))
    print((solve(N, As)))


# Optimized solution

def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

assert (gcd(10, 3) == 1)

def solve(N, As):
    k = min(As)
    for a in As:
        k = gcd(k, a)
    return k

if __name__ == "__main__":
    N = int(eval(input()))
    As = list(map(int, input().split(" ")))
    print((solve(N, As)))
# Original solution
def main():
    N = int(eval(input()))
    A = [int(i) for i in input().split()]
    minA = min(A)
    while any(a % minA for a in A):
        for i in range(N):
            if A[i] % minA:
                A[i] %= minA
        minA = min(A)
    print(minA)


if __name__ == '__main__':
    main()


# Optimized solution
def main():
    N = int(eval(input()))
    A = [int(i) for i in input().split()]

    def gcd(x, y):
        if y == 0:
            return x
        while y != 0:
            x, y = y, x % y
        return x

    g = A[0]
    for a in A[1:]:
        g = gcd(g, a)
    print(g)


if __name__ == '__main__':
    main()
# Original solution
N = int(eval(input()))
#A = [int(i) for i in input().split()]
A = list(map(int,input().split()))

def gcp(a,b):
    if b == 0:
        return a
    else:
        a,b = b,a%b
        return gcp(a,b)

a = A[0]
for i in range(1,N):
    a = gcp(a,A[i])
print(a)

# Optimized solution
N = int(eval(input()))
#A = [int(i) for i in input().split()]
A = list(map(int,input().split()))

def gcp(a,b):
    if b == 0:
        return a
    else:
        return gcp(b,a%b)

a = A[0]
for i in range(1,N):
    a = gcp(a,A[i])
print(a)
# Original solution
N = int(eval(input()))
monsters = list(map(int, input().split()))

monsters.sort(reverse=True)
#print(monsters)
ans = min(monsters)

while ans > 0:
    maxnum = max(monsters)
    minnum = min(monsters)
    maxidx = monsters.index(maxnum)

    if maxnum % minnum == 0:
        del monsters[maxidx]
        if len(monsters) == 1:
            print((monsters[0]))
            quit()
    else:
        ans = maxnum % minnum
        monsters[maxidx] = ans


# Optimized solution
N = int(eval(input()))
monsters = list(map(int, input().split()))

monsters.sort()  # 昇順
minnum = monsters[0]

cnt = len(monsters)
minidx = 0
while cnt > 1:
    for i in range(cnt - 1, 0, -1):
        monsters[i] = monsters[i] % monsters[0]

        if monsters[i] == 0:
            del monsters[i]

        elif monsters[i] == 1:
            print('1')
            quit()

    workmin = min(monsters)
    minidx = monsters.index(min(monsters))
    monsters[minidx] = monsters[0]
    monsters[0] = workmin

    cnt = len(monsters)

print((monsters[0]))
# Original solution
N = int(eval(input()))
A = set(map(int, input().split()))

while len(A) > 1:
    a = min(A)
    A = set(x - a if x != a else a for x in A)
    if 1 in A:
        A = {1}
print((list(A)[0]))

# Optimized solution
N = int(eval(input()))
A = set(map(int, input().split()))

while len(A) > 1:
    a = min(A)
    A = set(x % a if x % a != 0 else a for x in A)
    if 1 in A:
        A = {1}
print((list(A)[0]))
# Original solution
N = int(eval(input()))
A = set(map(int, input().split()))

while len(A) > 1:
    a = min(A)
    A = set(x % a if x % a != 0 else a for x in A)
    if 1 in A:
        A = {1}
print((list(A)[0]))

# Optimized solution
N = int(eval(input()))
A = set(map(int, input().split()))

while len(A) > 1:
    a = min(A)
    A = set(x % a if x % a != 0 else a for x in A)
print((list(A)[0]))
# Original solution
n = int(eval(input()))
a = list(map(int, input().split()))
while True:
  a.sort()
  t = sum(a)
  for i in range(1, len(a)):
    if a[i] % a[0] == 0:
      a[i] = a[0]
    else:
      a[i] = a[i] % a[0]
  if sum(a) == t:
    break
print((a[0]))

# Optimized solution
N = int(eval(input()))
A = list(map(int, input().split()))

while True:
    A.sort()
    t = sum(A)
    for i in range(1, N):
        if A[i] % A[0] == 0:
            A[i] = A[0]
        else:
            A[i] = A[i] % A[0]
    if sum(A) == t:
        break
print((A[0]))
# Original solution
n,*h=list(map(int,open(0).read().split()))
while len(h)>1:
    kh=set()
    for x in h:
        mn = min(h)
        md=x%mn
        if md!=0:
            kh.add(md)
        if len(kh)==mn-1:
            break
    kh.add(mn)
    h=kh
print(mn)

# Optimized solution
def gcd(a,b):
    if a%b==0:
        return b
    else:
        return gcd(b,a%b)

n,*h=list(map(int,open(0).read().split()))

gh=gcd(h[0],h[1])
for i in range(2,n):
    gh=gcd(h[i],gh)

print(gh)
# Original solution
from math import gcd
n = int(eval(input()))
a = list(map(int,input().split()))
p = a[0]
for i in range(1,n):
    p = gcd(p,a[i])
print(p)

# Optimized solution
from math import gcd
n = int(eval(input()))
a = list(map(int,input().split()))
ans = a[0]
for i in a[1:]:
    ans = gcd(ans,i)
print(ans)
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))

ans = 10 ** 10
while min(A) != ans:
    ans = min(A)
    for i, a_i in enumerate(A):
        if a_i > ans:
            A[i] = a_i % ans
            if A[i] == 0:
                del A[i]

print(ans)

# Optimized solution
N = int(eval(input()))
A = list(map(int, input().split()))


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def gcd_arr(a):
    ans = a[0]
    for i, a_i in enumerate(a):
        ans = gcd(ans, a_i)
    return ans

print((gcd_arr(A)))
# Original solution
N = int(eval(input()))
A = input().split(" ")
A = [int(i) for i in A]
list = [min(A)]
A = sorted(A)
iii = 0
while True:
    iii += 1
    if A[N-1] % A[N-2] != 0:
        A[N-1] = A[N-1] % A[N-2]
    elif N >= 3 and A[N-1] % A[N-3] != 0:
        A[N-1] = A[N-1] % A[N-3]
    elif N >= 4 and A[N-1] % A[N-4] != 0:
        A[N-1] = A[N-1] % A[N-4]
    elif N >= 5 and A[N-1] % A[N-5] != 0:
        A[N-1] = A[N-1] % A[N-5]
    elif N >= 6 and A[N-1] % A[N-6] != 0:
        A[N-1] = A[N-1] % A[N-6]
    elif N >= 7 and A[N-1] % A[N-7] != 0:
        A[N-1] = A[N-1] % A[N-7]
    elif N >= 8 and A[N-1] % A[N-8] != 0:
        A[N-1] = A[N-1] % A[N-8]
    elif N >= 9 and A[N-1] % A[N-9] != 0:
        A[N-1] = A[N-1] % A[N-9]
    elif N >= 10 and A[N-1] % A[N-10] != 0:
        A[N-1] = A[N-1] % A[N-10]
    elif N >= 11 and A[N-1] % A[N-11] != 0:
        A[N-1] = A[N-1] % A[N-11]
    elif N >= 12 and A[N-1] % A[N-12] != 0:
        A[N-1] = A[N-1] % A[N-12]
    elif N >= 13 and A[N-1] % A[N-13] != 0:
        A[N-1] = A[N-1] % A[N-13]
    elif N >= 14 and A[N-1] % A[N-14] != 0:
        A[N-1] = A[N-1] % A[N-14]
    elif N >= 15 and A[N-1] % A[N-15] != 0:
        A[N-1] = A[N-1] % A[N-15]
    elif N >= 16 and A[N-1] % A[N-16] != 0:
        A[N-1] = A[N-1] % A[N-16]
    elif N >= 17 and A[N-1] % A[N-17] != 0:
        A[N-1] = A[N-1] % A[N-17]
    elif N >= 18 and A[N-1] % A[N-18] != 0:
        A[N-1] = A[N-1] % A[N-18]
    elif N >= 19 and A[N-1] % A[N-19] != 0:
        A[N-1] = A[N-1] % A[N-19]

    A = sorted(A)
    list.append(min(A))
    if iii > 128:
        break       
#print(list)
for i in range(N-1):
    if A[i+1]-A[i] > 0:
        list.append(A[i+1]-A[i])
#print(list)
print((min(list)))

# Optimized solution
N = int(eval(input()))
A = input().split(" ")
A = [int(i) for i in A]
list = [min(A)]
A = sorted(A)
iii = 0
while True:
    iii += 1
    if A[N-1] % A[N-2] != 0:
        A[N-1] = A[N-1] % A[N-2]
    elif N >= 3 and A[N-1] % A[N-3] != 0:
        A[N-1] = A[N-1] % A[N-3]
    elif N >= 4 and A[N-1] % A[N-4] != 0:
        A[N-1] = A[N-1] % A[N-4]
    elif N >= 5 and A[N-1] % A[N-5] != 0:
        A[N-1] = A[N-1] % A[N-5]
    elif N >= 6 and A[N-1] % A[N-6] != 0:
        A[N-1] = A[N-1] % A[N-6]
    elif N >= 7 and A[N-1] % A[N-7] != 0:
        A[N-1] = A[N-1] % A[N-7]
    elif N >= 8 and A[N-1] % A[N-8] != 0:
        A[N-1] = A[N-1] % A[N-8]
    elif N >= 9 and A[N-1] % A[N-9] != 0:
        A[N-1] = A[N-1] % A[N-9]
    elif N >= 10 and A[N-1] % A[N-10] != 0:
        A[N-1] = A[N-1] % A[N-10]

    A = sorted(A)
    list.append(min(A))
    if iii > 96:
        break       
#print(list)
for i in range(N-1):
    if A[i+1]-A[i] > 0:
        list.append(A[i+1]-A[i])
#print(list)
print((min(list)))
# Original solution
N = int(eval(input()))
A = input().split(" ")
A = [int(i) for i in A]
list = [min(A)]
A = sorted(A)
iii = 0
while True:
    iii += 1
    if A[N-1] % A[N-2] != 0:
        A[N-1] = A[N-1] % A[N-2]
    elif N >= 3 and A[N-1] % A[N-3] != 0:
        A[N-1] = A[N-1] % A[N-3]
    elif N >= 4 and A[N-1] % A[N-4] != 0:
        A[N-1] = A[N-1] % A[N-4]
    elif N >= 5 and A[N-1] % A[N-5] != 0:
        A[N-1] = A[N-1] % A[N-5]
    elif N >= 6 and A[N-1] % A[N-6] != 0:
        A[N-1] = A[N-1] % A[N-6]
    elif N >= 7 and A[N-1] % A[N-7] != 0:
        A[N-1] = A[N-1] % A[N-7]
    elif N >= 8 and A[N-1] % A[N-8] != 0:
        A[N-1] = A[N-1] % A[N-8]
    elif N >= 9 and A[N-1] % A[N-9] != 0:
        A[N-1] = A[N-1] % A[N-9]
    elif N >= 10 and A[N-1] % A[N-10] != 0:
        A[N-1] = A[N-1] % A[N-10]

    A = sorted(A)
    list.append(min(A))
    if iii > 96:
        break       
#print(list)
for i in range(N-1):
    if A[i+1]-A[i] > 0:
        list.append(A[i+1]-A[i])
#print(list)
print((min(list)))

# Optimized solution
N = int(eval(input()))
A = input().split(" ")
A = [int(i) for i in A]
list = [min(A)]
A = sorted(A)
iii = 0
while True:
    iii += 1
    if A[N-1] % A[N-2] != 0:
        A[N-1] = A[N-1] % A[N-2]
    elif N >= 3 and A[N-1] % A[N-3] != 0:
        A[N-1] = A[N-1] % A[N-3]
    elif N >= 4 and A[N-1] % A[N-4] != 0:
        A[N-1] = A[N-1] % A[N-4]
    elif N >= 5 and A[N-1] % A[N-5] != 0:
        A[N-1] = A[N-1] % A[N-5]

    A = sorted(A)
    list.append(min(A))
    if iii > 64:
        break       
#print(list)
for i in range(N-1):
    if A[i+1]-A[i] > 0:
        list.append(A[i+1]-A[i])
#print(list)
print((min(list)))
# Original solution
import math
n = int(eval(input()))
A = tuple(map(int, input().split()))
g = A[0]
for a in A[1:]:
    g = math.gcd(g, a)
print(g)


# Optimized solution
n = int(eval(input()))
A = tuple(map(int, input().split()))
ma = min(A)
while True:
    ra = set([a%ma for a in A if a%ma > 0])
    if len(ra) == 0:
        print(ma)
        break
    minra = min(ra)
    if ma == minra:
        print(ma)
        break
    ma = minra
# Original solution
N = int(eval(input()))
An = [int(n) for n in input().split()]
M = sorted(set(An))
mini=M[0]
            
while len(M) > 1:
    M = [mini] + [x-mini for x in M[1:] if x % mini != 0]
    M.sort()
    if 1 in M:
        mini=1
        break
    mini = min(mini,M[0])
print(mini)    


# Optimized solution
N = int(eval(input()))
An = [int(n) for n in input().split()]
M = sorted(set(An))
mini=M[0]
            
while len(M) > 1:
    M = [mini] + [x%mini for x in M[1:] if x % mini != 0]
    M.sort()
    if 1 in M:
        mini=1
        break
    mini = min(mini,M[0])
print((M[0]))
# Original solution
def INT():
    return int(eval(input()))

def MI():
    return list(map(int, input().split()))

def LI():
    return list(map(int, input().split()))

from collections import deque
N = INT()
A = LI()
A.sort()

while True:
    mod = A[0]
    flg = True
    ans = A[0]
    tmp = deque([A[0]])
    
    if ans == 1:
        print(ans)
        break
    
    for i in range(1, len(A)):
        A[i] %= mod

        if A[i] != 0 and flg:
            flg = False
        
        if A[i] == 0:
            continue
        tmp.append(A[i])
        
    if flg:
        print(ans)
        break
    
    A = sorted(tmp)

# Optimized solution
def INT():
    return int(eval(input()))

def MI():
    return list(map(int, input().split()))

def LI():
    return list(map(int, input().split()))

from math import gcd

N = INT()
A = LI()
A.sort()
ans = A[0]

all_can_div = True

for i in range(1, N):
    A[i] = gcd(A[i], ans)
    
    if A[i] != ans and all_can_div:
        all_can_div = False

print((ans if all_can_div else min(A)))