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):
n = int(input())
xs = [int(x) for x in input().split()]

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

ret = xs[0]
for x in xs[1:]:
  ret = gcd(ret, x)
print(ret)

Solution (Python):
from queue import PriorityQueue
N = int(input())
A = map(int, input().split())
q = PriorityQueue()
for a in A:
  q.put(a)
x = q.get()
while not q.empty():
  y=q.get()
  if y == 0:
    continue
  q.put(x % y)
  x = y
print(x)

Solution (Python):
import itertools
def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)
n = map(int, input().split())
a = list(map(int, input().split()))
result = a[0]
for x in a[1:]:
    result = gcd(result, x)
print(result)

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


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

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

Solution (Python):
from queue import PriorityQueue
N = int(input())
A = map(int, input().split())
q = PriorityQueue()
for a in A:
    q.put(-a)
x = -q.get()
while not q.empty():
    y = -q.get()
    if y == 0:
        break
    q.put(-(x % y))
    x = y
print(x)

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):
N = int(input())
A = list(map(int, input().split()))
A.sort()

A_tmp=A[0]
for i in A[1:]:
  if i%A_tmp != 0:
    A_tmp = i%A_tmp
    
while(1):
  tmp = [x%A_tmp for x in A if x%A_tmp != 0]
  if sum(tmp) != 0:
    A_tmp = min(tmp)
  else:
    break
print(A_tmp)

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

Solution (Python):
from functools import reduce

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

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

print(reduce(gcd, a))

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
b=[]
e=False
while e==False:
    b=[]
    a_m=[]
    for i in a:
        if i!=0:
            a_m.append(i)
    
    temp=min(a_m)
    
    for i in a:
        g=i%temp
        if i==temp:
            b.append(i)
        elif g!=0:
            b.append(i%temp)
        
    
    
    
    if not b:
        ans=temp
        e=True
         
    else:
        if temp==min(b):
            ans=temp
            e=True
        else:
            a=b
     
                
print(ans)

Solution (Python):
import functools,fractions
n=int(input())
a=list(map(int,input().split()))
print(functools.reduce(fractions.gcd,a))

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


'''考え方
最大公約数が正解となる
'''


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


m,n = A[0],A[1]
gcd = f_gcd(m,n)


if len(A) >= 3:
  for i in A[2:]:
    gcd = f_gcd(gcd,i)
else:
  pass


print(gcd)

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

Solution (Python):
import sys
input = sys.stdin.readline

n = int(input())
A = list(map(int, input().split()))
ans = A[0]

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

for i in range(n-1):
    ans = calc(ans, A[i+1])

print(ans)

Solution (Python):
N = int(raw_input())
health = map(int, raw_input().strip().split())

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

if len(health) == 1:
	print(health[0])
else:
	g = gcd(health[0], health[1])
	for i in range(2, len(health)):
		g = gcd(g, health[i])
print(g)

Solution (Python):
N = int(raw_input())
health = map(int, raw_input().strip().split())
 
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
 
if len(health) == 1:
	print health[0]
else:
	g = gcd(health[0], health[1])
	for i in range(2, len(health)):
		g = gcd(g, health[i])
print g

Solution (Python):
N = int(raw_input())
health = map(int, raw_input().strip().split())

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

if len(health) == 1:
	print health[0]
else:
	g = gcd(health[0], health[1])
	for i in range(2, len(health)):
		g = gcd(g, health[i])
print g

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
l = len(A)
flag = 0
while flag == 0:
    flag = 1
    A.sort()
    for i in range(1, l):
        A[i] = A[i] % A[0]
        if A[i] == 0:
            A[i] = A[0]
    for i in A:
        if i != A[0]:
            flag = 0

print(A[0])

Solution (Python):
import numpy as np


def gcd(a, b):
    c = max(a,b)
    d = min(a,b)
    r = c % d
    if r == 0:
        return d
    else:
        return gcd(d, r)


monsterNum = int(input())
monsterHPArray = np.array(list(map(int, input().split())))
a = monsterHPArray[0]
for i in range(1, monsterNum):
    b = monsterHPArray[i]
    
    
    a = gcd(a, b)

print(a)

Solution (Python):
"""
import math
N = int(input())
A = list(map(int, input().split()))
g = math.gcd(A[0], A[1])
for a in A:
    if g == 1:
        break
    g = math.gcd(g, a)
print(g)
"""
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)
N = int(input())
A = list(map(int, input().split()))
g = gcd(A[0], A[1])
for a in A:
    if g == 1:
        break
    g = gcd(g, a)
print(g)

Solution (Python):
def get_gcd(a, b):
  m = max(a, b)
  n = min(a, b)
  while(True):
    if n == 0:
      return m
    r = m % n
    m = n
    n = r

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

a = A_list.pop()

while(len(A_list) > 0):
  b = A_list.pop()
  a = get_gcd(a, b)
  
print(a)

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

def gcm(x, y):
    x, y = max(x, y), min(x, y)
    while x%y > 0:
        x, y = y, x%y
    return y

a_gcd = a[0]
for i in range(n):
    a_gcd = gcm(a_gcd, a[i])
print(a_gcd)

Solution (Python):
from fractions import gcd

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

d = monster[0]
for m in monster[1:]:
    d = gcd(d, m)

print(d)

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

n=int(input())
arr=list(map(int,input().split()))
while len(arr)>1:
    a=arr.pop()
    b=arr[-1]
    arr[-1]=gcd(a,b)
print(arr[0])

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

init = a[0]
for i in a[1:]:
    if init >= i:
        x = init
        y = i
    else:
        x = i
        y = init
    z = x % y
    while z:
        x = y
        y = z
        z = x % y
    init = y

print(y)

Solution (Python):
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))
while True:
	min_a = A.min()
	new_A = np.where(A%min_a==0,min_a,A%min_a)
	A = new_A
	if (np.all(A == A[0])):
		break
print(A.min())

Solution (Python):
import fractions as frac
from functools import reduce
n=int(input())
a=[int(i) for i in input().split()]
def gcd_list(numbers):
    return reduce(frac.gcd, numbers)
print(gcd_list(a))

Solution (Python):
import numpy as np

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


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

min_HP = np.inf
a0 = As[0]
for a in As[1:]:
    b = gcd(a0,a)
    if b <= a0:
        a0 = b
print(a0)

Solution (Python):
import sys
import fractions
from functools import reduce
N = int(sys.stdin.readline())
A = list(set(map(int, sys.stdin.readline().split())))
print(reduce(fractions.gcd, A))

Solution (Python):
import fractions
from functools import reduce
n=int(input())
l=list(map(int,input().split()))
print(reduce(fractions.gcd,l))

Solution (Python):
from fractions import gcd
n=int(input())
a=[int(i) for i in input().split()]
g=a[0]
for i in range(1,len(a)):
    g=gcd(g,a[i])
print(g)

Solution (Python):
from fractions import gcd
from functools import reduce

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

print(reduce(gcd, a))

Solution (Python):
from functools import reduce
from fractions import gcd

n = int(input())

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

g = reduce(gcd, a)

print(g)

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

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()))
ans = gcd(*A)
print(str(ans))

Solution (Python):
from functools import reduce
def gcd (a: int,b: int) -> int:
    if a < b: a,b = b,a
    return a if b == 0 else gcd(b,a%b)
N = int(input())
print(reduce(gcd,list(map(int,input().split(" ")))))

Solution (Python):
from fractions import gcd
N = int(input())
list = [int(i) for i in input().split()]
gcd1 = min(list)
for i in list:
    gcd1 = gcd(i, gcd1)
print(gcd1)

Solution (Python):
from fractions import gcd
N = int(input())
list = [int(i) for i in input().split()]
gcd1 = list[0]
for i in list:
    gcd1 = gcd(i, gcd1)
print(gcd1)

Solution (Python):
import sys
input = sys.stdin.readline
from functools import reduce
def gcd_list(n):
    return reduce(gcd, n)

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

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

Solution (Python):
import sys
input = sys.stdin.readline
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:
    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()))
x=a[0]
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
for i in range(1,n):
    x=gcd(x,a[i])
print(x)

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

while(len(A) > 1):
    v = A[0]
    for i in range(1, len(A)):
        A[i] = A[i] % v
    for _ in range(A.count(0)):
        A.remove(0)
    A.sort()
print(A[0])

Solution (Python):
n=int(input())
l=[int(i) for i in input().split()]
x=ans=min(l)
while 1:
    t=[-1,-1]
    for i,j in enumerate(l):
        if j%x and ans>j%x:
            ans=j%x
            t[0]=i
            t[1]=ans
    l[t[0]]=ans
    x=ans
    if t[0]==-1: break


print(x)

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

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

if len(set(a_list)) == 1:
    print(a_list[0])
else:
    def euclidean_algorithm(a, b):
        a, b = min(a, b), max(a, b)
        while a > 0:
            a, b = b % a, a
        return b

    ans = a_list[0]
    for i in range(len(a_list) - 1):
        ans = euclidean_algorithm(ans, a_list[i + 1])
    print(ans)

Solution (Python):
import sys
import collections

b=[]
n = map(int, raw_input().split())
a = map(int, raw_input().split())

while True:
    a.sort()
    b=[]
    if a[0]==1:
        print(1)
        break
    elif a[0]==a[-1]:
        print(a[0])
        break
    else:
        for n in a:
            n=n%a[0]
            if n!=0:
                b.append(n)
        a=[a[0]]
        a.extend(b)

Solution (Python):
import numpy as np

n = int(input())
a = list(map(int,input().split(" ")))
while True:
    a = list(set(a))
    if 0 in a:
        a.remove(0)
    a.sort()
    
    mini = a[0]
    
    for i in range(1,len(a)):
        a[i] %= mini
    if len(a) == 1:
        
        print(mini)
        exit()

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

def solve(a):
    n = len(a)
    if n == 1:
        return a[0]
    b = []
    for i in range(0, n, 2):
        if i+1 < n:
            z = gcd(a[i], a[i+1])
        else:
            z = a[i]
        b.append(z)
    return solve(b)

assert solve([2,10,8,40]) == 2
assert solve([5,13,8,1000000000]) == 1
assert solve([1000000000,1000000000,1000000000]) == 1000000000
n = input()
a = list(map(int, input().split()))
print(solve(a))

Solution (Python):
from fractions import gcd

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

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

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

Solution (Python):
N=int(input())
a=list(map(int,input().split()))
def u(x,y):
    if x%y==0:
        return y
    else:
        return u(y,x%y)
b=list(range(N))
b[0]=a[0]
for i in range(1,N):
    b[i]=u(b[i-1],a[i])
print(int(b[N-1]))

Solution (Python):
def gcd(a,b):
    lt,gt = sorted([a,b])
    if lt == 0:
        return gt
    else:
        return gcd(gt % lt,lt)

def q3():
    N = int(input())
    A = list(map(int,input().split()))
    assert(N == len(A))
    ret = A[0]
    for n in range(1,N):
        ret = gcd(ret,A[n])
    print(ret)
    
q3()

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
while True:
  m = min(a)
  a = list(filter(lambda x: x!=0, [m] + [x%m for x in a]))
  if len(a)==1:
    break
print(a[0])

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

for i in range(1, N):
  a = A[i - 1]
  b = A[i]
  while a != b:
    if a < b:
      b -= (b // a) * a
      if b == 0:
        b = a
    else:
      a -= (a // b) * b
      if a == 0:
        a = b
  A[i - 1] = a
  A[i] = b
  
print(A[-1])

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

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

x = A[0]

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

print(x)

Solution (Python):
N = int(input())
import math

def gcd(a,b):
    if b==0:return a
    return gcd(b,a%b)
x = list(map(int,input().split()))

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 gcd(a,b):
    if(a%b==0):
        return b
    else:
        return gcd(b,a%b)
N = int(input())
s = [int(x) for x in input().split()]
tmp = s[0]
for i in s[1:]:
    tmp = gcd(tmp,i)
print(tmp)

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


def solve(a):
    min_a = min([elem for elem in a if elem != 0])
    new_a = [elem % min_a for elem in a]
    if len([elem for elem in new_a if elem == 0]) == len(a):
        return min_a
    new_a[new_a.index(0)] = min_a
    return solve(new_a)


print(solve(A))

Solution (Python):
N=int(input())
tmplist=list(map(int,input().split(" ")))
tmplist.sort()
tmplist.reverse()
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a
res=tmplist[0]
for a in range(1,N):
    res=gcd(tmplist[a],res)
print(res)

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

j=0
while True:
	if len(A)==1:
		break

	i=0
	while True:
		if i==len(A):
			break
		if A[i]<1:
			A.pop(i)
			i-=1
		i+=1

	A.sort()

	for i in range(1,len(A)):
		A[i]=A[i]%A[0]

	j+=1
print(A[0])

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

n = int(input())
s = [int(x) for x in input().split()]
tmp= s[0]
for i in s[1:]:
  tmp = gcd(tmp,i)
 
print(tmp)

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

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

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

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

def gcd(x,y):
    X = max(x,y)
    Y = min(x,y)
    if Y == 0:
        return X
    else:
        return gcd(Y,X%Y)

GCD = 10**9
for i in range(N-1):
    GCD = min(GCD,gcd(A[i],A[i+1]))

print(GCD)

Solution (Python):
n = int(input())
a = input().split()
for i in range(n):
    a[i] = int(a[i])
def gcm(a,b):
    if a >= b:
        if a % b == 0:
            return b 
        else:
            return gcm(b,a%b)
    else: return gcm(b,a)
for i in range(1,len(a)):
    a[0] = gcm(a[0],a[i])
print(a[0])

Solution (Python):
from sys import stdin

def fun():
    n = (int(i) for i in input().split())

    l = [int(x) for x in stdin.readline().rstrip().split()]

    l = list(set(l))
    l.sort()

    while 1 < len(l):
        k = len(l)
        for i in range(1, k):
            if l[k-i]%l[0] == 0:
                l.pop(k-i)
            elif l[k-i] - l[k-i-1] == 1:
                print(1)
                return
            else:
                l[k-i] = l[k-i]%l[0]
        
        l = list(set(l))
        l.sort()

        if l[0]==1:
            print(1)
            return

    print(l[0])
    return

if __name__ == '__main__':
    fun()

Solution (Python):


import sys

def gcd(a, b):

    c = min(a, b)
    d = max(a, b)
    r = 0    
    while True:
        r = d % c
        if r == 0:
            break
        d = c
        c = r

    return c

def parse_input(lines_as_string = None):

    lines = []
    if lines_as_string is None:
        for line in sys.stdin:
            lines.append(line)
    else:
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    
    nm = lines[0].split(" ")
    n = int(nm[0])

    rows = []
    for i in range(1, 2):
        rows.append([int(e) for e in lines[i].split(" ")])

    return (n, rows[0])

def solve(n, monsters):

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


    return g

def main():

    print("%d" % solve(*parse_input()))

if __name__ == '__main__':

    main()

Solution (Python):
def euclid(a,b):
    max_v=max(a,b)
    min_v=min(a,b)
    while 1:
        if max_v%min_v==0:
            return min_v
        tmp=max_v%min_v
        max_v=min_v
        min_v=tmp

        
    
if __name__=='__main__':
    n=int(input())
    hp=[int(i) for i in input().split()]
    cd=hp[0]
    for i in range(1,n):
        cd=euclid(cd,hp[i])
    print(cd)

Solution (Python):
def inpul(): return list(map(int, input().split()))

import fractions
from functools import reduce


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

N = inpul()
a = inpul()

ans = gcd_list(a)
print(ans)

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

data = set(A)

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

def culc(data):
  A_min=min(data)
  if set(map(lambda x: x%A_min,data))=={0}:
    return A_min
  A.sort()
  ans = A_min
  for i in A[1:]:
    ans=gdc(ans,i)
    if set(map(lambda x: x%ans,data))=={0}:
      return ans
  return ans

print(culc(data))

Solution (Python):
from functools import reduce
try:
    from math import gcd
except:
    from fractions import gcd

n = int(input())
a = [int(s) for s in input().split()]
print(reduce(gcd, a))

Solution (Python):
def euclid(x):
    def gcd(a,b):
        if b==0:return a
        return gcd(b,a%b)

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

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

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

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

m = A_arr[0]
for A in A_arr[1:]:
    m = gcd(m, A)

print(m)

Solution (Python):
import sys
import pprint

pp = pprint.PrettyPrinter(indent=4)

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

def main():
    """ Code implementation """
    n = int(input())
    healths = list(map(int, input().split()))
    m = healths[0]
    for i in range(1, len(healths)):
        if (m < healths[i]):
            g = gcd(m, healths[i])
        else:
            g = gcd(healths[i], m)
        if m > g:
            m = g

    print(m)

if __name__ == '__main__':
    main()

Solution (Python):




"""








"""
from fractions import gcd
from functools import reduce

def solve(nums):
    return reduce(gcd,nums)

def i():
    _ = input()
    return [int(i) for i in input().split()]


if __name__ == '__main__':
	print(solve(i()))

Solution (Python):
from functools import reduce

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

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

input()

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

print(gcd(*li))

Solution (Python):
from functools import reduce

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

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

def gcd(*num):
    return reduce(gcd_base, num)

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

print(gcd_list(A))

Solution (Python):
from fractions import gcd
n=int(input())
a=list(map(int,input().split()))
x=gcd(a[0],a[1])
for i in range(2,len(a)):
  x=gcd(x,a[i])
print(x)

Solution (Python):
import sys
import numpy as np

v = []
for line in sys.stdin:
  v.append([int(l) for l in line.split()])

m = np.array(v[1])

while len(m) != 1:
  min_m = np.min(m)
  arg_min_m = np.argmin(m)
  for idx, i in enumerate(m):
    if idx != arg_min_m:
      m[idx] %= min_m
  m = m[m!=0]
print(m[0])

Solution (Python):
def kumitate(a,b):
    a,b =max(a,b),min(a,b)
    while b != 0:
        a,b = b,a%b
    return a

N =int(input())
l =[int(i)for i in input().split()]
l =sorted(l)
mini =l[0]
for i in l:
    mini = kumitate(mini,i)
print(mini)

Solution (Python):
from fractions import gcd
n=int(input())
a=list(map(int,input().split()))
x=gcd(a[0],a[1])
for i in range(2,len(a)):
  x=gcd(x,a[i])
print(x)

Solution (Python):
import fractions
n = int(input())
aa = list(map(int, input().split()))
front = aa[0]
for a in aa[1:]:
  front = fractions.gcd(front, a)
print(front)

Solution (Python):
def main():
    N = int(input())
    health = set(map(int, input().split()))
    min_num = min(health)
    for i in health:
        while i % min_num != 0:
            temporary_min_num = min_num
            min_num = i % min_num
            i =  temporary_min_num
    print(min_num)

main()

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

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


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

def out(out_flag):
    print(out_flag)

out(out_flag)

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




def gcd(a, b):
    """
    自然数a, b の最大公約数を求める
    """
    if b == 0:
        return a
    else:
        return gcd(b, a % b)


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


print(ans)

Solution (Python):
n=int(input())
A=sorted(list(map(int,input().split())))
g=A[0]

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

for a in A:
  g=gcd(g,a)
print(g)

Solution (Python):
n = int(input())
aa = list(map(int, input().split()))
from fractions import gcd
from functools import reduce
ans = reduce(gcd, aa)

print(ans)

Solution (Python):


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



b=a[0]
c=a[1]
result=1
for i in range(1,n):
    while 1:
        if b%c == 0:
            result = c
            break
        else:
            r = b%c
            b = c
            c = r
    b=result
    c=a[i]
 
print(result)

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
while len(a)>1:
    m=min(a)
    def f(n):
        return n%m
    a=map(f,a)
    a=set(a)
    a.add(m)
    a.remove(0)
    a=list(a)
print(a[0])

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


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


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

print(ans)

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

def GCD(a, b):
    a, b = max(a, b), min(a, b)
    while a % b != 0:
        a, b = b, a%b
    return b

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

Solution (Python):
N = int(input())
L = [int(s) for s in input().split(' ')]

while len(L) > 1:
  L.sort()
  L_new = [L[0]]
  for l in L[1:]:
    v = l % L_new[0]
    if v != 0:
      L_new.append(v)
  L = L_new
print(L[0])

Solution (Python):
from queue import PriorityQueue
N = int(input())
A = map(int, input().split())
q = PriorityQueue()
for a in A:
    q.put(-a)
x = -q.get()
while not q.empty():
    y = -q.get()
    if y == 0:
        break
    q.put(-(x % y))
    x = y
print(x)

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

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

hitPoint.sort()

while not len(hitPoint) <= 1:
	a = hitPoint.pop(0)
	hitPoint = [ elem % a for elem in hitPoint if not elem % a == 0]
	hitPoint.append(a)
	hitPoint.sort()

print(hitPoint[0])

Solution (Python):
from functools import reduce
import fractions
def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)
def mon():
    input()
    a=[int(i) for i in input().split()]
    return gcd_list(a)
print(mon())

Solution (Python):

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

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

res = al[0]
for i in range(1,n):
    res = gcd(res,al[i])

print(res)

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

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

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

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

def f(l):
    m=min(l)
    li=[m]
    if m==sum(l):
        return m
    else:
        for i in range(len(l)):
            if l[i]%m!=0:
                li.append(l[i]%m)
        return f(li)

print(f(a))

Solution (Python):
def gcd(a, b):
    while b != a:
        if a < b:
            b = b % a
            if b == 0:
                return a
        elif b < a:
            a = a % b
            if a == 0:
                return b
    return a

def m(a):
    a.sort()
    l = len(a)
    b = []
    for i in range(l // 2):
        b.append(gcd(a[i], a[l - i - 1]))
    if l % 2 == 1:
        b.append(a[l // 2])
    return list(set(b))

    
n = int(input())
a = [int(x) for x in input().split(" ")]

while len(a) > 1:
    a = m(a)

print(a[0])

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


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

ans = mons[-1]
for i in mons:
    ans = gcd(ans, i)

print(ans)

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

Solution (Python):
def gcg(a,b):
    if b==0:
        return a
    else:
        return gcg(b,a%b)

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

res = l[0]
for i in range(1,n):
    res = gcg(res,l[i])
else:
    print(res)

Solution (Python):
gcd = lambda a, b: a if b == 0 else gcd(b, a % b)
N = int(input())
A = list(map(int, input().split()))
if A[0] < A[1]:
    tmp = A[0]
    A[0] = A[1]
    A[1] = tmp
c = gcd(A[0], A[1])
for i in range(2, N):
    if c < A[i]:
        tmp = c
        c = A[i]
        A[i] = tmp
    c = gcd(c, A[i])
print(c)

Solution (Python):
def gcd(a, b):
    q = a % b
    if q == 0:
        return b
    else:
        return gcd(b,q)
    
n = int(input())
li = list(map(int, input().split()))
ans = li[0]

for i in range(n-1):
    ans = gcd(ans, li[i+1])

print(ans)

Solution (Python):
import numpy as np

_ = input()
L = np.array(list(map(int, input().split())))

while True:
    th, index = np.amin(L), np.argmin(L)
    L = np.mod(L, th)
    L[index] = th
    L = L[L > 0]
    if len(L) == 1:
        print(L[0])
        break

Solution (Python):
N = int(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[-1]
for i in A:
    ans = gcd(ans, i)
print(ans)

Solution (Python):
gN = int(input())
gA = list(map(int,input().split()))

def attack():
    while True:
        minA = min(gA,key=lambda x: float('inf') if x==0 else x)
        maxA = max(gA)
        if minA == maxA:
            return minA

        for a in range(gN):
            if gA[a] == minA: continue
            gA[a] %= minA

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

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

a=A[0]
b=A[1]
gcd=1
for i in range(1,N):
  while 1:
    if a%b == 0:
      gcd=b
      break
    else:
      r = a%b
      a = b
      b = r
  a=gcd
  b=A[i]

print(gcd)

Solution (Python):
import fractions as fr
import functools as ft


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

cal1 = lambda x, y : fr.gcd(x, y)

print(ft.reduce(cal1, A))

Solution (Python):
import numpy as np

input()
A = np.sort(np.array(list(map(int, input().split()))))

while A.size > 1:
    A[1:] = A[1:] % A[0]
    A = np.setdiff1d(A, [0])

print(A[0])