Problem:
 Score : 300 points    Problem Statement There are N monsters, numbered 1, 2, ..., N .  Initially, the health of Monster i is A_i .  Below, a monster with at least 1 health is called alive.  Until there is only one alive monster, the following is repeated:   A random alive monster attacks another random alive monster.  As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking.   Find the minimum possible final health of the last monster alive.      Constraints  All values in input are integers.  2 \leq N \leq 10^5  1 \leq A_i \leq 10^9         Input Input is given from Standard Input in the following format:  N  A_1  A_2  ...  A_N       Output Print the minimum possible final health of the last monster alive.        Sample Input 1 4
2 10 8 40      Sample Output 1 2  When only the first monster keeps on attacking, the final health of the last monster will be 2 , which is minimum.       Sample Input 2 4
5 13 8 1000000000      Sample Output 2 1       Sample Input 3 3
1000000000 1000000000 1000000000      Sample Output 3 1000000000

Solution (Python):
import numpy as np
import math

n = int(input())
A = list(map(int, input().split()))
A = np.asarray(A)
A = np.sort(A)
while(A.size != 1):
    minimum = A[0]
    m = A.size
    B = np.asarray([minimum]*m)
    A = A%B
    A[0] = minimum
    A = A[A > 0]
    A = np.sort(A)
print(minimum)

Solution (Python):
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))

while np.count_nonzero(A) != 0:
    m = min(A)
    idx = list(A).index(m)
    A = A % m
    A[idx] = m
    A = A[np.nonzero(A)]
    if np.count_nonzero(A) == 1:
        break

print(A[0])

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
sort = sorted(A)













while len(sort) != 1:
  for i in range(1,len(sort)):
    sort[i] = sort[i]%sort[0]
  sort = [j for j in sorted(sort) if j != 0]

print(sort[0])

Solution (Python):
n = int(input())
l = list(map(int,input().split()))

minutes_mod = min(l)













new_l = list(set([i % minutes_mod for i in l]))
new_l.append(minutes_mod)
if 0 in new_l:
    new_l.remove(0)

another_list = list(set(new_l))
minutes = min(another_list)

while 1 :
    first_minutes = minutes
    another_list = list(set([i % minutes for i in another_list]))
    another_list.append(minutes)
    if 0 in another_list:
        another_list.remove(0)

    minutes = min(another_list)

    if first_minutes == minutes:
        break
print(minutes)

Solution (Python):
from functools import reduce

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

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
def gcd_list(numbers):
    return reduce(gcd, numbers)
m = gcd_list(A)
flag = 0
for i in range(N):
    if A[i] % m == 0:
        flag += 1
    else:
        pass
if flag == N:
    print(m)
else:
    print(1)

Solution (Python):
N = int(input())
A = [int(_) for _ in input().split()]
gcd = lambda x, y: gcd(y, x % y) if x % y else y
ans = A[0]
for i in range(1, N):
    ans = gcd(ans, A[i])
print(ans)

Solution (Python):
n = int(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)

Solution (Python):
def gcd(m,n):
    x = max(m,n)
    y = min(m,n)
    if x%y==0:
        return y
    else:
        while x%y!=0:
            z = x%y
            x = y
            y = z
        else:
            return z
n = int(input())
a = list(map(int,input().split()))
a.sort()
ans = a[0]
for i in range(1,n):
     ans = min(ans,gcd(ans,a[i]))
print(ans)

Solution (Python):
n,*a=map(int,open(0).read().split())
m=min(a)
while len(a)>1:
    m=min(a)
    f=0
    for i in range(len(a)):
        if a[i]!=m or f:
            a[i]%=m
        else:
            f=1
    *a,=filter(lambda x:x,a)
print(m)

Solution (Python):
import numpy as np
 
N=int(input())    
listA = list(map(int,input().split()))
 
minA = min(listA)
 
while True:
   minA = min(listA)
   minApos = np.argmin(listA)
   listA = [x % minA for x in listA]
   listA[minApos] = minA
   listA= [x for x in listA if x >0]
   if len(set(listA))==1:
       print(minA)
       break

Solution (Python):
def gcd(a, b):
  if b == 0:
    return a
  else:
    return(gcd(b, a % b))
  
N = int(input())
A = list(map(int, input().split()))
ans = 0
for i in range(N):
  if i == 0:
    ans = A[i]
  else:
    ans = gcd(ans, A[i])
print(ans)

Solution (Python):
n = int(input())
a = [ int(elem) for elem in input().split() ]
a.sort()

def calc(a):
    new_a = [ elem % a[0] if elem % a[0] != 0 else elem for elem in a ]
    new_a.sort()
    if new_a[0] == 1:
        return new_a[0]
    elif new_a[0] == a[0]:
        return a[0]
    else:
        return calc(new_a)

print(calc(a))

Solution (Python):
def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort()
    while True:
        if A[0] == 1:
            print(1)
            return
        for i in range(len(A)):
            if i == 0:
                continue
            else:
                if A[i] % A[0] != 0:
                    A[i] = A[i] % A[0]
                    A.sort()
                    break
            if i == len(A) - 1:
                print(A[0])
                return


if __name__ == "__main__":
    main()

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
num = len(A)

while num > 1:
    a = min(A)
    j = 0
    flag = True
    for n in range(num):
        if A[n] == a and flag:
            A[j] = a
            j += 1
            flag = False
        else:
            b = A[n] % a
            if b > 0:
                A[j] = b
                j += 1
    num = j

print(A[0])

Solution (Python):
N = int(input())
A = list(map(int, input().split(" ")))
A = [a for a in A if a >= 1]

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

temp = A[0]
for i in range(N-1):
    temp = gcd(temp, A[i+1])
    if temp == 1:
        break
print(temp)

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
ans = a[0]
for i in range(1,n):
    while a[i] % ans:
        a[i] = a[i] %ans
        if a[i] < ans:
            tmp = a[i]
            a[i] = ans
            ans = tmp
print(ans)

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


N = int(input())
A = list(map(int, input().split()))
num = A[0]
for i in range(N):
    num = gcd(num, A[i])
print(num)

Solution (Python):
n = int(input())
x = [int(i) for i in input().split()]

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


if n==1:
    print(x[0])
else:
    element = gcd(x[0], x[1])
    if n==2:print(element)
    else:
        for i in range(2,n):
            element=gcd(element,x[i])
        print(element)

Solution (Python):
def f(a, m):
  if a % m == 0:
    return m
  else:
    return a % m

def solve():
  N = int(input())
  A = list(map(int, input().split()))
  while True:
    m = min(A)
    A = list(map(lambda a: f(a, m), A))
    if all([a == m for a in A]): return m

print(solve())

Solution (Python):
def gcd(m, n):
  x = max(m, n)
  y = min(m, n)
  if x % y == 0:
    return y
  else:
    while x % y != 0:
      z = x % y
      x = y
      y = z
    else:
      return z
n = int(input())
a = list(map(int, input().split()))
lsize = len(a)
bef = a[0]
for i in range(1, lsize):
  bef = gcd(bef,a[i])
hp = bef
print(hp)

Solution (Python):
n = int(input())
l = [int(i) for i in input().split()]

m = []
flag = 0
while flag ==0:
    l.sort()
    p = len(l)
    for i in range(1,p):
        a = l[i]%l[0]
        if a != 0:
            l[i] = a
        else:
            l[i] = l[0]

    kkk = set(l)
    if len(kkk) <= 1 or min(l) == 1:
        flag = 1

if len(l) == 0:
    print(l[0])
else:
    l.sort()
    print(l[0])

Solution (Python):
n = int(input())
As = [int(i) for i in input().split()]

while True:
    m = min(As)
    idx = As.index(m)
    As = [a if i == idx else a % m for i, a in enumerate(As)]
    As = [a for a in As if a > 0]
    if len(As) == 1:
        break
print(As[0])

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
a = list(set(a))
while (10000000):
    a.sort()
    div_flag = True
    for i in range(1, len(a)):
        if a[i]%a[0] != 0:
            div_flag = False
    if div_flag is True:
        print(a[0])
        exit()
    for i in range(1, len(a)):
        a[i] = a[i]%a[0]
    while 0 in a :
        a.remove(0)

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
a.sort()

def gozyo():
    global a
    for i in range(1,len(a)):
        a[i]%=a[0]
    a.sort()
    while a[0]==0:
        a.pop(0)

while len(a)>1:
    gozyo()
print(a[0])

Solution (Python):
a_len = int(input())
a_list = list(map(int, input().split(' ')))


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


if a_len == 1:
    print(a_list[0])
else:
    element = gcd(a_list[0], a_list[1])
    if a_len == 2:
        print(element)
    else:
        for i in range(2, a_len):
            element = gcd(element, a_list[i])
        print(element)

Solution (Python):



def all_equal(num_list):
    return all([num_list[0] == num for num in num_list])


def self_injure(num_list):
    if all_equal(num_list):
        return num_list[0]
    if 1 in num_list:
        return 1
    hp_min = min(num_list)
    num_list2 = [hp_min if num % hp_min == 0 else num % hp_min for num in num_list]
    return self_injure(num_list2)


if __name__ == '__main__':
    N = int(input())
    monsters_hp = list(map(int, input().split()))
    hps = monsters_hp[:]

    print(self_injure(hps))

Solution (Python):

monster_num = int(input())
monster_hp_list = list(map(int, input().split(' ')))

while True:
    min_val = min(monster_hp_list)
    monster_hp_list = [i % min_val for i in monster_hp_list if i % min_val != 0]
    monster_hp_list.append(min_val)
    if len(monster_hp_list) == 1:
        break

print(monster_hp_list[0])

Solution (Python):
from fractions import gcd

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

sortedA = sorted(A)
answer = A[0]

for x in range(0,N):
        answer = gcd(answer,A[x])
        if answer == 1:
            break

print(answer)

Solution (Python):
n=int(input())

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

m = 0
while True:
  m = max(A)
  for i in range(n):
    if A[i] != 0:
      m = min(m,A[i])
  c = set(A) - set([0])
  if len(c) == 1:
    break
  
  for i in range(n):
    if A[i] == m:
      continue
    if A[i] == A[i]%m:
      continue
    else:
      A[i] = A[i]%m
print(m)

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

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

a.sort()

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

print(c)

Solution (Python):
N = int(input())
hp = list(map(int, input().split()))
while len(hp) > 1:
    m = min(hp)
    hp =[m] + [i % m for i in hp if i % m > 0]
print(m)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))

As = sorted(A)
As = [a%As[0] if a%As[0] != 0 else As[0] for a in As]
As = sorted(As)

def judge(tmp_one, tmp_two):
    flg = 1

    while flg:
        if tmp_two%tmp_one == 0:
            tmp_two = tmp_one
        else:
            tmp_two = tmp_two%tmp_one

        if tmp_one%tmp_two == 0:
            tmp_one = tmp_two
        else:
            tmp_one = tmp_one%tmp_two
        if tmp_one == tmp_two:
            flg = 0

    return tmp_one

tmp_one = As[0]
for i in range(1, N):
    if i == N - 1:
        tmp_two = As[i]
    elif As[i] != As[0]:
        tmp_two = As[i]
        break

tmp = judge(tmp_one, tmp_two)
print(tmp)

Solution (Python):
N = int(input())
A = [int(i) for i in input().split()]

A.sort()

a = A[0]
b = 0
if a % 2 == 0:
    for i in A[1:]:
        if i % 2 == 1:
            b = i
            
if b < a:
    b = A[1]

b -= int(b/a) * a

if b == 0:
    print(a)
    exit()

res = 0
while b > 0 and a > 0:
    na = max(a,b)
    nb = min(a,b)
    a = na - nb
    b = nb
    res = b
    

print(res)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
A.sort()

while len(A) > 1:
    n = A.pop(0)
    A = list(map(lambda x: x % n, A))
    A.sort()
    A.append(n)

    while 0 in A:
        A.pop(0)
print(A[0])

Solution (Python):


import math
import numpy as np
import random
import copy
import statistics 
import bisect
import heapq



N = int(input())
A = [-1 * int(x) for x in input().split()]

alives = N
A = sorted(A)

heap = heapq.heapify(A)
heap = A
num = 0
while alives > 1:
    biggest = -1 * heapq.heappop(heap)
    second = -1 * heapq.heappop(heap)
    times = int(math.floor(biggest / second))
    new_hp = biggest - second * times
    if new_hp <= 0:
        alives -= 1
    heapq.heappush(heap, second * -1)
    heapq.heappush(heap,new_hp * -1)
    num += 1

for a in A:
    if a < 0:
        print (a * -1)
        break

Solution (Python):
N = int(input())
A = [int(x) for x in input().split()]

A.sort()

m = A[0]

while True:
    flag = True
    new = list()
    for a in A:
        tmp = a % m
        if tmp != 0 and tmp < m:
            new.append(tmp)
            flag = False

    if flag:
        break
    else:
        m = min(new)

print(m)

Solution (Python):
def main():
    n=int(input())  
    a=list(map(int, input().split()))  
    num = a[0]

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


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

main()

Solution (Python):
import numpy as np
n = int(input())
data = np.array([int(i) for i in input().split()])
while True:
  datamin = data.min()
  data = data%datamin
  
  if data.sum()<=1:
    if data.sum()==0:
      print(datamin)
      exit()
    else:
      print(data[data>0].min())
      exit()
  data = np.append(datamin,data)
  data = data[data>0]

Solution (Python):
from heapq import heapify, heappush, heappop
n = int(input())
A = list(map(int, input().split()))
heapify(A)
while len(A) != 1:
    t = heappop(A)
    A = [a % t for a in A if a % t != 0]
    if A is None:
        A = [t]
        break
    heappush(A, t)
print(A[0])

Solution (Python):
import fractions
from functools import reduce
def gcd(numbers):
  return reduce(fractions.gcd, numbers)

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

Solution (Python):
import sys

def main():
  input = sys.stdin.readline
  N = int(input().strip())
  A = list(map(int, input().split()))
  
  a = min(A)
  B = [b % a for b in A if b % a != 0]
  if (len(B) == 0) or (min(B) == 0):
    print(a)
  else:
    b = min(B)
    while a % b != 0:
      c = b
      b = a % b
      a = c
    print(b)


if __name__ == '__main__':
  main()

Solution (Python):
n = int(input())

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

while True:
    a.sort()
    flag = True
    j = 0
    while a[j] == 0:
        j += 1
    for i in range(j+1,n):
        a[i] %= a[j]
        if a[i] != 0:
            flag = False
    if flag:
        break 

print(a[j])

Solution (Python):

N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
a = A[0]
for i in range(N - 1):

    b = A[i + 1]
    plus = a % b
    while plus != 0:
        a = b
        b = plus
        plus = a % b
    a = b
print(a)

Solution (Python):
input()
a = [int(v) for v in input().split()]
ans = None
while True:
        mi = float('inf')
        for v in a:
                if v == 0:
                        continue
                mi = min(mi, v)
        if mi == float('inf'):
                break
        if ans is None or mi < ans:
                ans = mi
        zero_cnt = 0
        for i in range(len(a)):
                if a[i] % mi == 0:
                        zero_cnt += 1
                        continue
                a[i] %= mi
        if zero_cnt == len(a):
                break
print(ans)

Solution (Python):
import numpy as np

s = int(input())
A = list(map(int, input().split()))

A = np.array(sorted(A))
ans = A[0]
np.delete(A, 0)

while True:
    B = A % ans
    C = B[B != 0]
    if len(C) == 0:
        break
    ans = min(C)
    B = C

print(ans)

Solution (Python):
import numpy as np

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

np_lst = np.array(lst)
min_val = np.min(np_lst)

ans = -1
while(True):
    tmp = set(np_lst%min_val)
    tmp = tmp - set([0])
    if min_val == 1:
        ans = 1
        break
    elif len(tmp) == 0:
        ans = min_val
        break
    else:
        if min(tmp) < min_val:
            min_val = min(tmp)
        else:
            ans = min_val
            break

print(ans)

Solution (Python):


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


A.sort()
l = len(A)

tmp1 = list(A)
tmp2 = []

while len(tmp1) > 1:
    m = tmp1[0]
    tmp2.append(m)
    for d in tmp1:
        a = d % m
        if 0 < a < d:
            tmp2.append(a)
    tmp2.sort()
    tmp1 = tmp2
    tmp2 = []

print(tmp1[0])

Solution (Python):
N=int(input())
L=list(map(int,input().split()))



def f(l, s):
    return s if l % s == 0 else f(s, l % s)
    
z = f(max(L), min(L))

for i in L:
    z=f(i,z)
ans=10000000000
for i in range(len(L)):
    if L[i]%z==0:
        pass
    elif L[i]%z<ans:
        ans=L[i]%z

if ans==10000000000:
    print(z)
else:
    print(ans)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
while len(a) > 1:
    s = min(a)
    a = [i%s for i in a]
    a = [j for j in a if j != s and j >= 1]
    a.append(s)
print(a[0])

Solution (Python):
import numpy as np

def input_numbers():
    temp = list(map(int, input().split()))
    return temp

def GCD(a, b):
    if(a < b):
        temp = a
        a = b
        b = temp
    a = a % b
    if(a == 0):
        return b
    else:
        return GCD(a, b)

n = int(input())
a = input_numbers()

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

print(g)

Solution (Python):
import fractions

N = int(input())
A = [int(x) for x in input().split()]

x = fractions.gcd(A[0],A[1])

for i in range(2,N):
    x = fractions.gcd(A[i],x)

print(x)

Solution (Python):
from functools import reduce

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

n = int(input())
lst = list(map(int, input().split()))
 
def gcd_list(numbers):
    return reduce(gcd, numbers)
 
print(gcd_list(lst))

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
A.sort()

flag = 0
i = 1
while flag == 0:
    if A[i] % A[0] != 0:
        A[i] = A[i] % A[0]
        A[i],A[0] = A[0],A[i]
        i = 1
    else:
        i += 1
        if i == N:
            flag = 1
            print(A[0])
            exit()

Solution (Python):
from functools import reduce
def gcd(x, y): 
  
   while(y): 
       x, y = y, x % y 
  
   return x 
  


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

n=int(input())
inp=input().split(" ")
mons=[int(i) for i in inp]
print(lcm_list(*mons))

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

while True:
    if len(a) == 1:
        break
    a.sort()
    for i in range(len(a)-1, 0, -1):
        a[i] %= a[0]
        if a[i] == 0:
            del a[i]
print(a[0])

Solution (Python):
import fractions

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

A.sort()

res = A[0]
for aa in A:
    res = fractions.gcd(res, aa)

print(res)

Solution (Python):
n=int(input())
tmp=list(map(int, input().split(" ")))
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

def lcm(a, b):
	return a * b // gcd (a, b)

a=max(tmp)
for i in tmp:
    a=gcd(a,i)

print(a)

Solution (Python):

import sys
import math
import numpy as np
import itertools



n = int(input())


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

def gcd(p,q):
    if p < q:
        r = p
        p = q
        q = r
    if q == 0:
        return p
    r = p % q
    return gcd(q,r)
        

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

Solution (Python):
import fractions
N = int(input())
A = list(map(int, input().split()))
GCD_i=A[0]
for i in range(len(A)):
  GCD_i = fractions.gcd(GCD_i,A[i])
print(GCD_i)

Solution (Python):

import sys

import math



"""Template"""


class IP:
    """
    入力を取得するクラス
    """
    def __init__(self):
        self.input = sys.stdin.readline

    def I(self):
        """
        1文字の取得に使います
        :return: int
        """
        return int(self.input())

    def S(self):
        """
        1文字の取得(str
        :return: str
        """
        return self.input()

    def IL(self):
        """
        1行を空白で区切りリストにします(int
        :return: リスト
        """
        return list(map(int, self.input().split()))

    def SL(self):
        """
        1行の文字列を空白区切りでリストにします
        :return: リスト
        """
        return list(map(str, self.input().split()))

    def ILS(self, n):
        """
        1列丸々取得します(int
        :param n: 行数
        :return: リスト
        """
        return [int(self.input()) for _ in range(n)]

    def SLS(self, n):
        """
        1列丸々取得します（str
        :param n: 行数
        :return: リスト
        """
        return [self.input() for _ in range(n)]

    def SILS(self, n):
        """
        Some Int LineS
        横に複数、縦にも複数
        :param n: 行数
        :return: list
        """
        return [self.IL() for _ in range(n)]

    def SSLS(self, n):
        """
        Some String LineS
        :param n: 行数
        :return: list
        """
        return [self.SL() for _ in range(n)]


class Idea:
    def __init__(self):
        pass

    def HF(self, p):
        """
        Half enumeration
        半分全列挙です
        pの要素の和の組み合わせを作ります。
        ソート、重複削除行います
        :param p: list : 元となるリスト
        :return: list : 組み合わせられた和のリスト
        """
        return sorted(set(p[i] + p[j] for i in range(len(p)) for j in range(i, len(p))))

    def Bfs2(self, a):
        """
        bit_full_search2
        bit全探索の改良版
        全探索させたら2進数のリストと10進数のリストを返す
        :return: list２つ : １個目 2進数(16桁)  2個目 10進数
        """
        
        
        
        value = []
        for i in range(1 << len(a)):
            output = []

            for j in range(len(a)):
                if self.bit_o(i, j):
                    """右からj+1番目のiが1かどうか判定"""
                    
                    output.append(a[j])
            value.append([format(i, 'b').zfill(16), sum(output)])

        value.sort(key=lambda x: x[1])
        bin = [value[k][0] for k in range(len(value))]
        val = [value[k][1] for k in range(len(value))]
        return bin, val

    def S(self, s, r=0, m=-1):
        """
        ソート関係行います。色々な設定あります。
        :param s: 元となるリスト
        :param r: reversするかどうか 0=False 1=True
        :param m: （2次元配列）何番目のインデックスのソートなのか
        :return: None
        """
        r = bool(r)
        if m == -1:
            s.sort(reverse=r)
        else:
            s.sort(reverse=r, key=lambda x: x[m])

    def bit_n(self, a, b):
        """
        bit探索で使います。0以上のときにTrue出します
        自然数だからn
        :param a: int
        :param b: int
        :return: bool
        """
        return bool((a >> b & 1) > 0)

    def bit_o(self, a, b):
        """
        bit探索で使います。1のときにTrue出すよ
        oneで1
        :param a: int
        :param b: int
        :return: bool
        """
        return bool(((a >> b) & 1) == 1)

    def ceil(self, x, y):
        """
        Round up
        小数点切り上げ割り算
        :param x: int
        :param y: int
        :return: int
        """
        return -(-x//y)

    def ave(self, a):
        """
        平均を求めます
        :param a: list
        :return: int
        """
        return sum(a) / len(a)

    def d(self, p):
        re = 0
        for i in range(len(p) - 1):
            re += ((p[i][0] - p[i + 1][0]) ** 2 + (p[i][1] - p[i + 1][1]) ** 2) ** 0.5
        return re

    def gcd(self, x, y):
        if y == 0:
            return x
        else:
            return self.gcd(y, x % y)  


"""ここからメインコード"""


def main():
    
    r, e = range, enumerate
    ip = IP()
    id = Idea()

    """この下から書いてね"""
    n = ip.I()
    a = ip.IL()
    res = max(a)

    for i in r(n):
        res = min(res, id.gcd(a[0], a[i]))

    print(res)


main()

Solution (Python):
from functools import reduce
n = int(input())
a = list(map(int, input().split()))
def gcd(a, b):
    """Return greatest common divisor using Euclid's Algorithm."""
    while b:      
        a, b = b, a % b
    return a
def gcmm(*args):
  return reduce(gcd, args)
print(gcmm(*a))

Solution (Python):
from sys import stdin
n = int(stdin.readline().rstrip())
a = [int(x) for x in stdin.readline().rstrip().split()]
while True:
    ma = min(a)
    a = [x % ma for x in a]
    a = [ma if x == 0 else x for x in a]
    if max(a) == min(a):
        print(min(a))
        exit()

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

while True:
    if len(a) == 1:
        break
    a.sort()
    for i in range(len(a)-1, 0, -1):
        a[i] %= a[0]
        if a[i] == 0:
            del a[i]
print(a[0])

Solution (Python):
n = int(input())
A = list(map(int,input().split()))
while True:
    if A.count(0) == n - 1:
        print(max(A))
        exit()
    else:
        B = [ _  for _ in A if _ != 0  ]
        attack = min(B)
        sn = A.index(attack)
        
        for i in range(n):
            if A[i] == 0:
                pass
            else:
                if i != sn:
                    A[i] = A[i] % attack
                else:
                    pass

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
while True:
    m = max(a)
    for i in range(n):
        if a[i] > 0 and a[i] < m:
            m = a[i]
    ind = a.index(m)
    count = 0
    for i in range(n):
        if i != ind:
            a[i] = a[i]%m
        if a[i] == 0:
            count += 1
    if count == n-1:
        print(a[ind])
        break

Solution (Python):
N = int(input())
hp = list(map(int, input().split()))
hp.sort()

def gcd(a, b):
    if b < a:
        tmp = a
        a = b
        b = tmp
    p = b // a
    r = b % a
    while r != 0:
        b = a
        a = r
        p = b // a
        r = b % a
    return a

ans = hp[0]
for i in range(len(hp) - 1):
    ans = gcd(ans, hp[i+1])

print(ans)

Solution (Python):
n = int(input())
ai = list(map(int, input().split(' ')))
while len(ai) > 1:
    ai = list(sorted(list(ai)))
    ai_head = ai[0]
    ai = list(filter(lambda x: x != 0, map(lambda x: x%ai_head, list(ai[1:]))))
    ai.append(ai_head)
print(ai[0])

Solution (Python):
N = int(input())
HP = [int(i) for i in input().split()]
m = min(HP)
while(HP.count(m) < N):
    HP = [i % m if i % m != 0 else m for i in HP]
    m = min(HP)

print(m)

Solution (Python):
def gcd(x, y):
  if y == 0:
    return x
  else:
    return gcd(y, x % y)

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

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

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

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

def gcd_list(a):
  for i in range(n - 1):
    a[i + 1] = gcd(a[i], a[i + 1])
  return a[n - 1]
  
print(gcd_list(a))

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

from functools import reduce
def gcds(*numbers):
    print(reduce(gcd, numbers))
    
gcds(*list(map(int, input().split(" "))))

Solution (Python):


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

min_A = min(A)

while True:
    for i in range(N):
        if A[i] == min_A:
            continue
        A[i] = A[i] % min_A
    min_A = min([i for i in A if i!= 0])
        
    if max(A)==1:
        print(min_A)
        break

    if max(A) == min_A:
        print(min_A)
        break

Solution (Python):
def gcd(m, n):
    x = max(m, n)
    y = min(m, n)
    if x%y == 0:
        return y
    else:
        while x%y != 0:
            z = x%y
            x = y
            y = z
        else:
            return z
    
N = int(input())
A = [int(x) for x in input().split()]

for i in range(N):
    if i == 0:
        tmp = A[i]
    if i == N:
        break
    else:
        tmp = gcd(tmp, A[i])

print(tmp)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
L = []
minA = min(A)
for i, a in enumerate(A):
  if a % minA != 0:
    L.append(a % minA)
if len(L) == 0:
  print(minA)
  exit()
L.append(minA)
L = list(set(L))
while len(L) > 1:
  L.sort()
  for i, l in enumerate(L):
    if i == 0:
      continue
    L[i] = l - L[0]
  L = list(set(L))
print(L[0])

Solution (Python):
import sys

import numpy as np

sys.setrecursionlimit(200000)


def input():
    return sys.stdin.readline()[:-1]


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


def dfs(A):
    m = min(A[A != 0])  
    
    sub_A = A[1:] % m  
    ans = np.insert(sub_A[sub_A != 0], 0, m)  
    if len(ans) != 1:
        ans = dfs(np.sort(ans))
    return ans


def solve():
    N = ii()
    A = np.array(sorted(il()))
    return dfs(A).item()


if __name__ == "__main__":
    print(solve())

Solution (Python):
n = int(raw_input())
l = map(int, raw_input().split())
l = list(set(l))

while True:
    if len(l)==1:
        print(l[0])
        break
    else:
        ml = min(l)
        l = [i % ml for i in l]
        l.append(ml)
        l = filter(lambda x: x > 0, l)
        l = list(set(l))
        if len(l)==1:
            print(l[0])
            break
        ml = min(l)
        l = [i - ml for i in l]
        l.append(ml)
        l = filter(lambda x: x > 0, l)
        l = list(set(l))

Solution (Python):
import math
from functools import reduce
aaa = int(input())
baa = list(map(int, input().split()))


def gcd (a,b):
    if (b == 0):
        return a
    else:
        return gcd(b, a % b)
res = baa[0]
for c in baa[1::]:
    res = gcd(res , c)
print(res)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
A.sort()

for i in range(N-1):
    while True:
        A[i+1] %= A[i]
        A[i+1], A[i] = A[i], A[i+1]
        if A[i] == 1:
            print(1)
            exit(0)
        elif A[i] == 0:
            break

print(A[-1])

Solution (Python):
import numpy as np

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

minA = min(listA)

while True:
    minA = min(listA)
    minApos = np.argmin(listA)
    listA = [x % minA for x in listA]
    listA[minApos] = minA
    listA= [x for x in listA if x >0]
    if len(set(listA))==1:
        print(minA)
        break

Solution (Python):


"""
Created on 2019/2/16
Solved on 2019/2/16
@author: shinjisu
"""



def getInt(): return int(input())


def getIntList(): return [int(x) for x in input().split()]


def zeros(n): return [0]*n


def getIntLines(n): return [int(input()) for i in range(n)]


def getIntMat(n):
    mat = []
    for i in range(n):
        mat.append(getIntList())
    return mat


def zeros2(n, m): return [zeros(m)]*n


def dmp(x):
    global debug
    if debug:
        print(x)
    return x


def gcd(x, y):  
    m = max(x, y)
    n = min(x, y)
    while m % n != 0:
        w = m % n
        m = n
        n = w
    return n


def probC():
    N = getInt()
    A = getIntList()
    dmp((N, A))
    hp = A[N-1]
    for i in range(N-1):
        hp = gcd(hp, A[i])
        dmp(hp)
    return hp


debug = False  
print(probC())


def probD():
    N = getInt()
    A = getIntList()
    dmp((N, A))
    return 123


def probA():
    A, B = getIntList()
    dmp((A, B))
    if B % A == 0:
        return A+B
    else:
        return B-A


def probB():
    N, M = getIntList()
    A = getIntMat(N)
    dmp((N, M))
    dmp(A)
    food = set([])
    food = set(A[0][1:])
    dmp(food)
    for i in range(N):
        food2 = set(A[i][1:])
        food = food & food2
        dmp(food)
    return len(food)