CodeEff/ECCO huggingface dataset:
# Original solution
n = int(eval(input()))
a = list(map(int, input().split()))
a.sort()

for i in range(1, len(a)):
    while 0 != a[i - 1]:
        r = a[i] % a[i - 1]
        a[i] = a[i - 1]
        a[i - 1] = r
print((a[-1]))


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


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


def gcd_for_arr(l):
    tmp = gcd(l[0], l[1])
    for i in range(2, len(l)):
        tmp = gcd(tmp, l[i])
    return tmp


print((gcd_for_arr(a)))
# Original solution
def gcd(m, n):
    while n:  # nが0になるまで繰り返す
        m, n = n, m % n
    return m


n = int(eval(input()))  # n体のモンスター
a = list(map(int, input().split()))  # それぞれの体力

g = gcd(a[0], a[1])  # 最大公約数を求める
for i in range(2, n):
    g = gcd(g, a[i])  # 最初のgは1つ目と2つ目の要素の最大公約数がすでに入っている

print(g)


# Optimized solution
def gcd(m, n):
    while n:  # nが0になるまで続ける
        m, n = n, m % n
    return m


N = int(eval(input()))  # モンスターの数

A = list(map(int, input().split()))  # モンスターのそれぞれの体力のリスト

g = gcd(A[0], A[1])

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

print(g)
# Original solution
import sys
stdin = sys.stdin
def li(): return list(map(int, stdin.readline().split()))
N = li()
A = list(li())

def gcd(A, B):
    # fast return
    if B == 1 or A == 1:
        return 1

    # normal gcd logic
    while B not in (1, 0):
        A, B = min(A, B), abs(A - B)
    if B == 0:
        return A
    elif B == 1:
        return 1

A = list([x for x in A if x>0])
A.sort()
if len(A) == 0:
    print((0))
else:
    res = A[0]
    for a in A:
        res = gcd(a, res)
        if res == 1:
            break

    print(res)


# Optimized solution
import sys
stdin = sys.stdin
def li(): return list(map(int, stdin.readline().split()))
N = li()
A = list(li())

def gcd(A, B):

    # normal gcd logic
    while B not in (1, 0):
        A, B = (A, B) if A > B else (B, A)
        _, mod = divmod(A, B)
        A, B = B, mod
    if B == 0:
        return A
    elif B == 1:
        return 1

A = list([x for x in A if x>0])
A.sort()
if len(A) == 0:
    print((0))
else:
    res = A[0]
    for a in A:
        res = gcd(a, res)
        if res == 1:
            break

    print(res)
# Original solution
N = int(eval(input()))
A = [int(i) for i in input().split()]
A.sort()

def calc(a, b):
    while(a != b):
        largeNum = max(a, b)
        smallNum = min(a, b)
        largeNum -= smallNum
        a = largeNum
        b = smallNum
    return a

ans = 1
for i in range(0, N - 1):
    a = calc(A[i], A[i+1])
    A[i], A[i+1] = a, a
    if a == 1:
        break
else:
    ans = min(A)

print(ans)

# Optimized solution
N = int(eval(input()))
A = [int(i) for i in input().split()]
A.sort(reverse = True)

def calc(a, b):
    largeNum = max(a, b)
    smallNum = min(a, b)
    while(largeNum != 0 and smallNum != 0):
        largeNum %= smallNum
        x = largeNum
        largeNum = smallNum
        smallNum = x
    return max(smallNum, largeNum)

ans = 1
for i in range(0, N - 1):
    a = calc(A[i], A[i+1])
    A[i], A[i+1] = a, a
    if a == 1:
        break
else:
    ans = min(A)

print(ans)
# Original solution
n=int(eval(input()))
a=list(map(int,input().split()))

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

def search_list_common_divisor(*numbers):
    c=[numbers[0][i] for i in range(n)]
    b=[search_common_divisor(c[0],c[1])]
    for i in c:
        b.append(search_common_divisor(b[-1],i))
    return b[-1]

print((search_list_common_divisor(a)))


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

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

def search_list_common_divisor(*numbers):
    b=[search_common_divisor(numbers[0],numbers[1])]
    for i in numbers:
        b.append(search_common_divisor(b[-1],i))
    return b[-1]

print((search_list_common_divisor(*a)))
# Original solution
n = int(eval(input()))
monster= list(map(int,input().split()))

while True:
    index_list = [i for i, v in enumerate(monster) if v >0]
    mini = monster[index_list[0]]
    for i in range(1, len(index_list)):
        if mini > monster[index_list[i]]:
            mini =  monster[index_list[i]]

    miniindex_list = [i for i, v in enumerate(monster) if v ==mini]
    min_index = miniindex_list[0]

    for i in range(len(monster)):
        if not i == min_index:
            monster[i] = monster[i] % monster[min_index]
            
    non_zeroindex_list = [i for i, v in enumerate(monster) if v >0] 
    non_zeroindex = non_zeroindex_list[0]
    if len(non_zeroindex_list) == 1:
        break
print((monster[non_zeroindex]))

# Optimized solution
n = int(eval(input()))
monsters = list(map(int, input().split()))
def gcd(a, b):
    if b == 0:  
        return a
    else:
        return gcd(b, a%b)
gcd(4,2)

def gcd_more(a):
    ans = a[0]
    for i in range(1,len(a)):
        ans = gcd(ans, a[i])
    return ans
print((gcd_more(monsters)))
# Original solution
from functools import reduce


def gcd(a, b):
    if b > a:
        a, b = b, a
    dp = [a, b]
    for i, v in enumerate(dp, start=2):
        dp.append(dp[i - 2] % dp[i - 1])
        if dp[i] == 0:
            break
    return dp[i - 1]


N = int(eval(input()))
a = list(map(int, input().split()))
print((reduce(gcd, a)))


# Optimized solution
import math

n = int(eval(input()))
a = list(map(int, input().split()))
ans = 0
for i in a:
    ans = math.gcd(ans, i)

print(ans)
# Original solution
from heapq import heapify, heappush, heappop
N = int(eval(input()))
Alist = list(map(int, input().split()))
heapify(Alist)
while len(Alist)>1:
    Alist = [a for a in Alist if a > 0]
    min_num = heappop(Alist)
    for i in range(len(Alist)):
        Alist[i] %= min_num
    heappush(Alist, min_num)
print((Alist[0]))

# Optimized solution
from heapq import heapify, heappop, heappush
N = int(eval(input()))
Alist = list(map(int, input().split()))
heapify(Alist)
while len(Alist) > 1:
    atk = heappop(Alist)
    Alist = [A % atk for A in Alist if (A % atk != 0)]
    heapify(Alist)
    heappush(Alist, atk)
print((Alist[0]))
# Original solution
n=int(eval(input()))
hoge=list(map(int,input().split()))
###
def huga(a,b):
  x=max(a,b)
  y=min(a,b)
  z=1
  for i in range(y):
    wa=y-i
    if(x%wa==0 and y%wa==0):
      z=wa
      break
  return z
###
hoge.sort(reverse=True)
ans=hoge[0]
for i in range(n-1):
  ans=huga(ans,hoge[i+1])
  
print(ans)

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

n=int(eval(input()))
hoge=list(map(int,input().split()))
hoge.sort()
for i in range(n-1):
  hoge[i+1]=gcd(hoge[i],hoge[i+1])
  
print((hoge[-1]))
# Original solution
n = int(eval(input()))
a = list(map(int, input().split()))
a = list(set(a))

while len(a) > 1:
    mina = min(a)
    for i in a:
        if i == mina:
            continue
        elif i % mina == 0:
            a.remove(i)
        else:
            a[a.index(i)] = i % mina
            
print((a[0]))

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

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

g = a[0]

for i in a:
    g = gcd(g, i)

print(g)
# Original solution
n = int(eval(input()))
a = list(map(int, input().split()))

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

g = a[0]

for i in a:
    g = gcd(g, i)

print(g)

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

min_ind = a.index(min(a))

while True:
    min_num = min(a)
    min_ind = a.index(min_num) 
    a = [n % min_num for n in (a[:min_ind] + a[min_ind+1:]) if n % min_num != 0]
    if a == []:
        print(min_num)
        exit()
    a.append(min_num)
# Original solution
N=int(eval(input()))
A=list(map(int,input().split()))
while len(A)>=2:
    A=sorted(A,reverse=True)
    while 1:
        if not A[-1]:
            A.pop()
        else:
            for i in range(len(A)-1):
                A[i]%=A[-1]
            break
print((A[0]))


# Optimized solution
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
N=int(eval(input()))
A=list(map(int,input().split()))
num=A[0]
for i in range(1,N):
    num=gcd(num,A[i])
print(num)
# Original solution
N = int(eval(input()))
lista = sorted(list(map(int, input().split())))
length = len(lista)
while length>1:
    #print(length)
    #print(lista)
    for n in range(1, length):
        lista[n] = lista[n]%lista[0]
    #print(lista)
    lista.sort()
    #print(lista)
    lista = list(set(lista))
    if lista[0] == 0:
        lista.remove(0)
    #print(lista)
    length = len(lista)
print((lista[0]))  

# Optimized solution
N = int(eval(input()))
lista = sorted(list(map(int, input().split())))
length = 2
while length>1:
    #print(length)
    #print(lista)
    for n in range(1, length):
        lista[n] = lista[n]%lista[0]
    #print(lista)
    lista = list(set(lista))
    lista.sort()
    if lista[0] == 0:
        lista.remove(0)
    #print(lista)
    length = len(lista)
print((lista[0]))
# Original solution
from functools import reduce


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


def gcd_n(numbers):
    return reduce(gcd, numbers)


def main():
    N, *A = list(map(int, open(0).read().split()))
    print((gcd_n(A)))
    return


main()


# Optimized solution
def main():
    N, *A = list(map(int, open(0).read().split()))
    b = None
    for a in A:
        if b is None:
            b = a
            continue
        while b:
            a, b = b, a % b
        b = a
    print(a)
    return


main()
# Original solution
# coding: utf-8
# Your code here!
N=int(eval(input()))
A=list(map(int,input().split()))

a=min(A)
ans=0

for i in range(1,int(a**0.5)//1+1):
    judge=True
    for item in A:
        if item%i!=0:
            judge=False
    if judge:
        ans=max(ans,i)

    judge=True
    for item in A:
        if item%(a//i)!=0:

            judge=False
    if judge:
        ans=max(ans,(a//i))
        
print(ans)

# Optimized solution
# coding: utf-8
# Your code here!
N=int(eval(input()))
A=list(map(int,input().split()))

a=min(A)
ans=0
l=[]

def gcd(lis,num):
    temp=[]
    for item in lis:
        if num%item!=0:
            pass
        else:
            temp.append(item)
    return temp

for i in range(1,int(a**0.5)//1+1):
    if a%i==0:
        l.append(i)
        l.append(a//i)

for item in A:
    l=gcd(l,item)

print((max(l)))
# Original solution
###C - Monsters Battle Royale
N = int(eval(input()))
A = list(map(int, input().split()))

while(len(set(A)) != 1):
    for i in range(N):
        minA  = min(A)
        if A[i] > minA:
            time = A[i] // minA
            if time == 1:
                A[i] =A[i] -  time * minA
            else:
                A[i] =A[i] -  (time - 1) * minA
                
print((min(A)))

# Optimized solution
###C - Monsters Battle Royale
N = int(eval(input()))
A = list(map(int, input().split()))

while(len(set(A)) != 1):
    minA  = min(A)
    for i in range(N):
        if A[i] > minA:
            time = A[i] // minA
            if time == 1:
                A[i] =A[i] -  time * minA
            else:
                A[i] =A[i] -  (time - 1) * minA
                
print((min(A)))
# Original solution
n = int(eval(input()))
a = list(map(int,input().split()))
a = sorted(list(set(a)))
while len(a) > 1:
  b = a.pop()
  d = []
  for i in a:
    c = b%i
    if c != 0:
      d.append(c)
  a = sorted(list(set(d+a)))
print((a[0]))

# Optimized solution
n = int(eval(input()))
a = list(map(int,input().split()))
a = sorted(list(set(a)))
while len(a) > 1:
  b = a.pop(0)
  d = []
  for i in a:
    c = i%b
    if c != 0:
      d.append(c)
  a = sorted(list(set(d+[b])))
print((a[0]))
# Original solution
N = int(eval(input()))
Flag = [0 for i in range(N)]
A = list(map(int,input().split()))
while len(A) != 1:
    A.sort()
    mi = min(A)
    for _ in range(1,len(A)):
        if A.count(1) > 1:
            del A[1:]
            break
        try:
            A[_] -= mi
            if A[_] <= 0:
                A.pop(_)
        except:
            pass
print((A[0]))

# Optimized solution
N = int(eval(input()))
A = list(map(int,input().split()))
while len(A) > 1:
    a_ = A[0]
    for x in range(1,len(A)):
        A[x] %= a_
    A = [ans for ans in A if ans > 0]
    A.sort()
print((A[0]))
# Original solution
def uauau():
    N = int(eval(input()))
    aA=sorted(set(int(_) for _ in input().split()))
    N = len(aA)
    def ggg(i,j):
        i %= j
        if i == 0:
            return j
        else:
            return ggg(j,i)

    if len(aA) == 1:
        print((aA[0]))
    else:
        iMin = aA[0]
        iMax = aA[-1]
        if iMin  == 1:
            print((1))
        else:
            iMt = max(i % iMin for i in aA)
            if iMt == 0:
                print(iMin)
                exit()
            elif iMt  == 1:
                print((1))
            else:
                iM = iMax
                for i in range(N):
                    iA = aA[i]
                    for j in range(i+1,N):
                        if aA[j] % iA != 0:
                            iMt = ggg(aA[j],iA)
                            if iMt < iM:
                                iM = iMt
                    if iM == 1:
                        print((1))
                        exit()
                print(iM)
uauau()


# Optimized solution
#gcdか....
def fgcd(a,b):
    while b:
        a,b = b,a%b
    return a

N = int(eval(input()))
aA = sorted(set(int(_) for _ in input().split()))
b = aA[0]
for a in aA[1:]:
    b = fgcd(a,b)
print(b)
# Original solution
#gcdか....
def fgcd(a,b):
    while b:
        a,b = b,a%b
    return a

N = int(eval(input()))
aA = sorted(set(int(_) for _ in input().split()))
b = aA[0]
for a in aA[1:]:
    b = fgcd(a,b)
print(b)


# Optimized solution
N = int(eval(input()))
aA=[int(_) for _ in input().split()]
iMin = min(aA)
iMax = max(aA)

def fgcd(a,b):
    while b:
        a,b = b,a%b
    return a

if iMin  == 1:
    print((1))
else:
    iDm = [ _ % iMin for _ in aA]
    if max(iDm) == 0:
        print(iMin)
    else:
        b = aA[0]
        for _ in aA[1:]:
            b = fgcd(_,b)
            if b == 1:
                print((1))
                exit()
        print(b)
# Original solution
N  = int(eval(input()))

data = [int(i) for i in input().split()]

i = 0
def euq(x,y):
  a = max(x,y)
  b = min(x,y)
  if a % b == 0:
    return b
  else:
  	return euq(b, a % b)
  


while i < N-1:
  com =  euq(data[i],data[i + 1])
  data[i+1] = com
  i += 1
  
  

print(com)


# Optimized solution
n = int(eval(input()))
data = [int(s) for s in input().split()]

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


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

# 体力最小のモンスターが他全員に攻撃することを繰り返す。ただし体力0にはしない
# 全員同じ体力になったら終了

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

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

# 体力最小のモンスターが他全員に攻撃することを繰り返す。ただし体力0にはしない
# 全員同じ体力になったら終了

while len(set(A)) >= 2:
    A = list(set(A))
    min_A = min(A)
    A = [x%min_A if x%min_A != 0 else min_A for x in A]
    
print((A[0]))
# Original solution
N = int(eval(input()))
A = list(map(int,input().split()))
def gcd(m, n):
  while n:
    m, n = n, m%n
  return m

ans = A[0]
tmp = []
for i in range(1,N):
  tmp.append(gcd(ans,A[i]))
print((min(tmp)))

# Optimized solution
def gcd(m, n):
  while n:
    m, n = n, m%n
  return m

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

def gcd(m, n):
  while n:
    m, n = n, m%n
  return m

def lcm(m, n):
  return (m*n)//gcd(m, n)

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

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

def gcd(m, n):
  while n:
    m, n = n, m%n
  return m

ans = A[0]
for i in range(1,N):
  ans = gcd(ans, A[i])
print(ans)
# Original solution
n = int(eval(input()))
a = sorted(list(map(int, input().split())))
while True:
    a = sorted(list(set(a)))
    tmp = sorted(a[:20])
    for i in tmp:
        if i == a[0]:
            continue
        elif i % a[0] == 0:
            a.remove(i)
        else:
            a.append(i % a[0])
            a.remove(i)
    if len(a) == 1:
        break
print((a[0]))


# Optimized solution
n = int(eval(input()))
a = sorted(list(map(int, input().split())))
while True:
    a = sorted(list(set(a)))
    tmp = sorted(a[:])
    for i in tmp:
        if i == a[0]:
            continue
        elif i % a[0] == 0:
            a.remove(i)
        else:
            a.append(i % a[0])
            if i % a[0] == 1:
                print((1))
                exit()
            a.remove(i)
    if len(a) == 1:
        break
print((a[0]))
# Original solution
N = int(eval(input()))
L = list(map(int,input().split()))
L = sorted(L)
while True:
    for i in range(1,len(L)):
        L[i] %= L[0]
    L= [x for x in L if x!=0]
    L= sorted(L)
    if len(L) == 1:
        break
print((L[0]))


# Optimized solution
def gcd(x , y):
    if x < y:
        x , y = y , x
    if y == 0:
        return x
    r = x % y
    return gcd(y , r)

N = int(eval(input()))
L = list(map(int,input().split()))
ans = L[0]
for i in range(len(L)):
    ans = gcd( ans ,L[i] )
print(ans)
# Original solution
N = int(eval(input()))
L = list(map(int,input().split()))
L.sort()
def gcd(x,y):
  while y != 0:
    k = x
    x = y
    y = k%y
  return x
G = gcd(L[0],L[1])
for i in range(1,N-1):
  if G >= gcd(L[i],L[i+1]):
    G = gcd(L[i],L[i+1])
print(G)

# Optimized solution
N = int(eval(input()))
L = list(map(int,input().split()))
L.sort()
def gcd(x,y):
  while y != 0:
    k = x
    x = y
    y = k%y
  return  x
cur = L[0]
for i in range(N):
  cur = gcd(cur,L[i])
print(cur)
# Original solution
n = int(eval(input()))
a = list(map(int, input().split()))

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

g = a[0]
for i in range(n-1):
    g = gcd(g, a[i+1])

print(g)

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

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

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

print(g)
# Original solution
n = int(eval(input()))
a = list(map(int, input().split()))

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

g = a[0]
for i in range(n-1):
    g = gcd(g, a[i+1])

print(g)

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

def gcd(x, y):
    if x < y:
        x, y = y, 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)
# Original solution
n = int(eval(input()))
aa = list(map(int,input().split()))

# print(aa)
def mod(xx):
    bb=[]
    minX = min(xx)
    for i in range(len(xx)):
        b = xx[i] % minX if xx[i]>min(xx) else xx[i]
        if b>0:
            bb.append(b)
    return list(set(bb))

while True:
    bb = mod(aa)
    # print(bb)
    if min(aa)==min(bb) or min(bb)==1:
        break
    aa=bb
print((min(bb)))

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

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

ans=aa[0]
for i in range(1,n):
    ans = gcd(ans, aa[i])
print(ans)
# Original solution
import heapq

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

heapq.heapify(A)
flag = True

while flag:
    minA = heapq.heappop(A) # 最小値を取り出す
    if len(A) == 0: # 要素がなかったら終わり
        break
    if minA == 0: # 0だったら除外したまま続ける
        continue
    A = list([x % minA for x in A])
    heapq.heappush(A, minA)

print(minA)

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

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

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

print(ans)
# Original solution
N = int(eval(input()))
A = [int(i) for i in input().split()]

def attack(A):
  A = list(set(A))
  A.sort()
  if A[0] ==0:
    A.pop(0)
  attack_mons = A[0]
  new_A = [A[0]]
  for i in range(1,len(A)):
    new_A.append(A[i]%min(A))
  return new_A

new_A = attack(A)
while A!=new_A:
  A = new_A
  new_A = attack(new_A)

print((min(new_A)))


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

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

ans = A[0]

for a in A:
  ans = gcd(ans,a)

print(ans)
# Original solution
a = eval(input())
list = input().split()
b = len(list)
for j in range(b):
	list[j] = int(list[j])
for k in range(b-1):
	l = k + 1
	while l < b:
		if list[k] > list[l]:
			temp = list[k]
			list[k] = list[l]
			list[l] = temp
		l += 1
gcd = int(list[0])
for i in range(b):
	m = list[i] 
	n = gcd
	while n != 0:
		m,n = n,m%n
	if(m<gcd):
		gcd = m
print(gcd)

# Optimized solution
a = eval(input())
list = list(map(int,input().split()))
b = len(list)
gcd = int(list[0])
for i in range(b):
	m = list[i] 
	n = gcd
	while n != 0:
		m,n = n,m%n
	if(m<gcd):
		gcd = m
print(gcd)
# Original solution
from heapq import heapify, heappush, heappop

def main():
    N = int(eval(input()))
    A = list(map(int, input().split()))
    heapify(A)
    while len(A) > 1:
        m = heappop(A)
        A = [a % m for a in A if a % m != 0]
        A.append((m))

    print(m)


if __name__ == "__main__":
    main()

# Optimized solution
def main():
    N = int(eval(input()))
    A = list(map(int, input().split()))
    while len(A) > 1:
        m = min(A)
        A = [a % m for a in A if a % m != 0]
        A.append((m))

    print(m)


if __name__ == "__main__":
    main()
# Original solution
n = int(eval(input()))
A = [int(i) for i in input().split()]
while True:
    if len(A) == 1:
        print((A[0]))
        break
    A[A.index(max(A))] %= min(A)
    if 0 in A:
        A.remove(0)

# Optimized solution
n = int(eval(input()))
A = [int(i) for i in input().split()]

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

for i in range(n - 1):
    A[i + 1] = gcd(A[i], A[i + 1])
    
print((A[-1]))
# 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

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

print(gcd_A)


# 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

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

print(gcd_calc)
# Original solution
#priority_queueで管理
#普通にソートすればいいじゃん
n=int(eval(input()))
a=sorted([int(i) for i in input().split()])
#print(a)
while len(a)!=1:
    b=a[0]
    for i in range(1,n):
        a[i]-=b*(a[i]//b)
    a=sorted([i for i in a if i!=0])
    n=len(a)
    #print(a)

print((a[0]))


# Optimized solution
n=int(eval(input()))
a=list(map(int,input().split()))
while len(a)>1:
    l=len(a)
    a.sort()
    b=[a[0] if i==0 else a[i]%a[0] for i in range(l)]
    a=[b[i] for i in range(l) if b[i]!=0]
print((a[0]))