You are given N monsters, each with an initial health value. Monsters attack each other randomly until only one is left alive. During each attack, the health of the attacked monster decreases by the health of the attacking monster. Find the minimum possible final health of the last monster alive. Constraints: 2 ≤ N ≤ 10^5, 1 ≤ Ai ≤ 10^9. Input format: N followed by N health values. Output the minimum possible final health of the last monster alive.

# Buggy version:
import fractions

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

# Fixed version:
from math import gcd

n = int(input())
a = list(map(int, input().split()))
ans = a[0]
for i in range(n):
  ans = gcd(ans, a[i])
print(ans)

# Buggy version:
N=int(input())
A=list(map(int,input().split()))
B=A[0]
def gcd(a,b):
  while b:
    a,b=b,a%b
  return a
for i in range(1,N):
  B=gcd(B,A[i])
prnt(B)

# Fixed version:
N=int(input())
A=list(map(int,input().split()))
B=A[0]
def gcd(a,b):
  while b:
    a,b=b,a%b
  return a
for i in range(1,N):
  B=gcd(B,A[i])
print(B)

# Buggy version:
N = int(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(n):
    ans = gcd(ans, A[i])

    print(ans)

# Fixed version:
N = int(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(N):
    ans = gcd(ans, A[i])

print(ans)

# Buggy version:
N =int(input())
A = list(map(int, input().split()))

#２整数の最大公約数を求める

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



#N 整数の最大公約数を求める
#A = [A[0],...,A[N]] とする

def gcd(A):
    ans = A[0]
    for i in range(1,N) #range(1,N)= 1,2,...,N-1
        ans = gcd(ans, A[i])
    return ans
print(gcd(A))

# Fixed version:
N =int(input())
A = list(map(int, input().split()))

#２整数の最大公約数を求める

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



#N 整数の最大公約数を求める
#A = [A[0],...,A[N]] とする

def gcd(A):
    ans = A[0]
    for i in range(1,N): #range(1,N)= 1,2,...,N-1
        ans = gcd2(ans, A[i])
    return ans
print(gcd(A))

# Buggy version:
N=int(input())
HP=list(map(int,input().split()))

tmp=egcd(HP[0],HP[1])

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)

# Fixed version:
def egcd(a, b):
    (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)
    gcd=a
    return gcd

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

tmp=egcd(HP[0],HP[1])

for i in range(1,N-1):
    tmp=egcd(tmp,HP[i+1])
    
print(tmp)

# Buggy version:
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
def gcdl(l):
    from functools import reduce
    reduce(lambda x, y: gcd(x, y), a)
n=input()
print(gcdl(list(map(int,input().split()))))

# Fixed version:
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
def gcdl(l):
    from functools import reduce
    return reduce(lambda x, y: gcd(x, y), l)
n=input()
print(gcdl(list(map(int,input().split()))))

# Buggy version:
n=int(input())
l=list(map(int,input().split()))
ans=0
def gcd(a,b):
    if b==0:return a
    return gcd(b,a%b)
if n==1:
    ans=x[0]
else:
    element = gcd(x[0], x[1])
    if n==2:
      ans=element
    else:
        for i in range(2,n):
            element=gcd(element,x[i])
        ans=element
print(ans)

# Fixed version:
n=int(input())
l=list(map(int,input().split()))
ans=0
def gcd(a,b):
    if b==0:return a
    return gcd(b,a%b)
if n==1:
    ans=l[0]
else:
    element = gcd(l[0], l[1])
    if n==2:
      ans=element
    else:
        for i in range(2,n):
            element=gcd(element,l[i])
        ans=element
print(ans)

# Buggy version:
N = int(input())
a = list(map(int,input().split()))
ans = a[0]
for i in range(1,N):
  ans = gcd(ans,a[i])
print(ans)

# Fixed version:
import math
N = int(input())
a = list(map(int,input().split()))
ans = a[0]
for i in range(1,N):
  ans = math.gcd(ans,a[i])
print(ans)

# Buggy version:
import math
print(reduce(math.gcd,map(int,input().split())))

# Fixed version:
import math
import functools
input()
print(functools.reduce(math.gcd,map(int,input().split())))

# Buggy version:
n=int(input())
a=[map(int,input().split()) for i in range(n)]
b=a[0]
def gcd(x,y):
  while y:
    x,y=y,x%y
  return x

for i in a:
  b=gcd(b,i)
print(b)

# Fixed version:
n=int(input())
a=[int(i) for i in input().split()]
b=a[0]
def gcd(x,y):
  while y:
    x,y=y,x%y
  return x

for i in a:
  b=gcd(b,i)
print(b)

# Buggy version:
n = int(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)

# Fixed version:
n = int(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)

# Buggy version:
import sys 
stdin = sys.stdin
ns = lambda : stdin.readline().rstrip()
ni = lambda : int(ns())
na = lambda : map(int, stdin.readline().split())

n = ni()
a = list(na())

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

ans = 1
for e in a:
  ans = gcd(ans, e)
print(ans)

# Fixed version:
import sys 
stdin = sys.stdin
ns = lambda : stdin.readline().rstrip()
ni = lambda : int(ns())
na = lambda : map(int, stdin.readline().split())

n = ni()
a = list(na())

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

ans = a[0]
for e in a[1:]:
  ans = gcd(ans, e)
print(ans)

# Buggy version:
N = int(input())
A = [int(n) for n in input().split()]

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

temp_gcm = gcm(A[0],A[1])
 for i in range(2,N):
     temp_gcm = gcm(A[i],temp_gcm)
print(temp_gcm)


# Fixed version:
N = int(input())
A = [int(n) for n in input().split()]

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

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

# Buggy version:
from functools import reduce


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


def lcm(x, y):
    return (x * y) // gcd(x, y)


def gcd_list(*numbers):
    return reduce(gcd, numbers)


def lcm_list(*numbers):
    return reduce(lcm, numbers)


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

print(gcd_list(a))

# Fixed version:
from functools import reduce


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


def lcm(x, y):
    return (x * y) // gcd(x, y)


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


def lcm_list(numbers):
    return reduce(lcm, numbers)


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

print(gcd_list(a))

# Buggy version:
n = int(input())
lst_a = list(map(int, input().split()))

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

ans = lst_a[0]
for a in lst_a:
    # 配列の最初からひとつずつ最大公約数を取っていけばよい。
    ans = gcd(ans, a)

print(ans)

# Fixed version:
n = int(input())
lst_a = list(map(int, input().split()))

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

ans = lst_a[0]
for a in lst_a:
    # 配列の最初からひとつずつ最大公約数を取っていけばよい。
    ans = gcd(ans, a)

print(ans)

# Buggy version:
from math import gcd
n = int(input())
a = list(map(int,input().split()))

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

print(i)


# Fixed version:
from math import gcd
n = int(input())
a = list(map(int,input().split()))

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

print(g)

# Buggy version:
n = int(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
gcd_more(monsters)

# Fixed version:
n = int(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))

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

n = int(input())
line = list(map(int,input().split()))

ans = line[0]

for i in range(1,n):
    ans = gcd(ans,line[i])

print(ans)

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

n = int(input())
line = list(map(int,input().split()))

ans = line[0]

for i in range(1,n):
    ans = gcd(ans,line[i])

print(ans)

# Buggy version:
n= int(input())
a_list = list(map(int, input().split()))
gcd = a_list[0]
for i in range(1,n):
    gcd = math.gcd(gcd,a_list[i])
    
    
print(gcd)

# Fixed version:
import math
n= int(input())
a_list = list(map(int, input().split()))
gcd = a_list[0]
for i in range(1,n):
    gcd = math.gcd(gcd,a_list[i])
    
    
print(gcd)

# Buggy version:
N = int(input())
A = list(map(int,input().split()))
now = A[0]
for i in range(1,N):
    now = math.gcd(A[i],now)
print(now)

# Fixed version:
import math
N = int(input())
A = list(map(int,input().split()))
now = A[0]
for i in range(1,N):
    now = math.gcd(A[i],now)
print(now)

# Buggy version:
input()
A = list(map(int, input().split(" ")))
A.sort()
def gcd(a, b):
    while b:
        a, b = b, a%b
    return a
rtn = 0
for i in range(0,len(A)-1):
    print(A[i], A[i+1], gcd(A[i], A[i+1]))
    A[i+1] = gcd(A[i], A[i+1])
print(A[-1])

# Fixed version:
input()
A = list(map(int, input().split(" ")))
A.sort()
def gcd(a, b):
    while b:
        a, b = b, a%b
    return a
rtn = 0
for i in range(0,len(A)-1):
    A[i+1] = gcd(A[i], A[i+1])
print(A[-1])

# Buggy version:
N = int(input())
monsters = list(map(int, input().split()))
def gcd(a, b):
	if b > 0 :
      return gcd(b , a % b)
    else :
      return x
if len(monster) == 1 :
	print(monster[0])
else :
    mon = gcd(monster[0], monster[1])
    if len(monster) >= 2
    for i in range(2 , N) :
      mon = gcd(mon, monster[i])
print(mon)
    
    
    
     


# Fixed version:
N = int(input())
monster = list(map(int, input().split()))
def gcd(a, b):
	if b > 0 :
		return gcd(b, a % b)
	else:
		return a
if len(monster) == 1 :
	print(monster[0])
else:
	mon = gcd(monster[0], monster[1])
	if len(monster) != 2 :
		for i in range(2, N) :
			mon = gcd(mon, monster[i])
print(mon)

# Buggy version:
from fractions import gcd
from functools import reduce
n=int(input())
a=list(map(int,input().split()))
def gcd(*numbers):
    return reduce(math.gcd, numbers)
def gcd_list(numbers):
    return reduce(math.gcd, numbers)
print(gcd_list(a))

# Fixed version:
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

n = int(input())
print(gcd_list(list(map(int,input().split()))))