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):


"""
参考：https://img.atcoder.jp/abc118/editorial.pdf
"""

import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians, log10
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd 
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul, xor
from copy import copy, deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def round(x): return int((x*2+1) // 2)
def fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD
def lcm(x, y): return (x * y) // gcd(x, y)
def lcm_list(nums): return reduce(lcm, nums, 1)
def gcd_list(nums): return reduce(gcd, nums, nums[0])
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()
A = LIST()

print(gcd_list(A))

Solution (Python):
n = int(input())
alist = list(map(int,input().split()))
i_roop = 1
while i_roop > 0 :
  alist.sort()
  n = len(alist)  
  k = min(alist)
  if k == sum(alist) :
    break
  else:
    for j in range(1,n):
      alist[j] = alist[j] % k
  
  alist = [i for i in alist if not i  == 0]  
print(alist[0])

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

while True:
  mini = min(A)
  newA = []
  op = False
  for i in A:
    if i == mini:
      newA.append(i)
    elif i % mini == 0:
      newA.append(mini)
    else:
      newA.append(i % mini)
  A = newA
  if len(set(A)) == 1:
    break

print(A[0])

Solution (Python):
import sys
sys.setrecursionlimit(1000000)

def gcd(i,j):
  if i>j:
    i,j=j,i
  if j%i==0:
    return i
  return gcd(j-i,i)

n=int(input())
l=[int(i) for i in input().split()]
l.sort()
g=gcd(l[0],l[1])
for i in range(2,len(l)):
  g=gcd(g,l[i])
print(g)

Solution (Python):
n = int(input())
A = [int(a) for a in input().split()]
A.sort()
while(len(A)!=1):  
    n = A[0]
    A = map(lambda _: _% n, A[1:])
    A = [n] + [a for a in A if a != 0]
    A.sort()
    
print(A[0])

Solution (Python):



n = int(input())
hp = list(map(int, input().split()))
while len(hp) != 1:
    minhp = min(hp)
    hp = [i % minhp if not i == minhp else i for i in hp]
    hp = [i for i in hp if not i == 0]
    if min(hp) == 1:
        minhp = min(hp)
        break
    elif hp == [minhp for i in hp]:
        break
print(minhp)

Solution (Python):
N = int(input())
A = [int(x) for x in input().split()]
s = min(A)
d = [x % s for x in A]
while max(d) > 0 and s > 1:
  d = [e for e in d if e > 0] + [s]
  s = min(d)
  d = [x % s for x in d]
print(s)

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


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


ans = gcd(a[0], a[1])

for i in range(2, len(a)):
    ans = gcd(ans, a[i])

print(ans)

Solution (Python):


import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians, log10
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd 
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul, xor
from copy import copy, deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def round(x): return int((x*2+1) // 2)
def fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD
def lcm(x, y): return (x * y) // gcd(x, y)
def lcm_list(nums): return reduce(lcm, nums, 1)
def gcd_list(nums): return reduce(gcd, nums, nums[0])
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()
A = LIST()

A.sort()
mn = A[0]
i = 1
while i < N and mn > 1:
    div = A[i] % mn
    if div != 0 and mn > div:
        mn = div
        i = 0
    else:
        i += 1
print(mn)

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


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


if __name__ == "__main__":
    main()

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

while 1 < len(A):
	low = min(A)
	A.remove(low)

	A = map(lambda x: x%low, A)
	A = list(filter(lambda x: x>0, A))

	A.append(low)

print(A[0])

Solution (Python):
from fractions import *
from functools import *

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

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

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

print(reduce(gcd, an))

Solution (Python):

"""
a,b = map(int, input().split())
if b % a == 0:
    print(b + a)
else:
    print(b-a)
"""


"""
n, m = map(int, input().split())
ans = input().split()
del ans[0]
for i in range(n-1):
    a = input().split()
    del a[0]
    for k in ans:
        if k in a:
            continue
        else:
            ans.remove(k)
    if len(ans) == 0:
        break
print(len(ans))
"""

import fractions
from functools import reduce

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

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

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

Solution (Python):
a = int(input())
list = input().split()
for j in range(a):
	list[j] = int(list[j])
gcd = list[0]
for i in range(a):
	m = list[i] 
	n = gcd
	while n != 0:
		m,n = n,m%n
	if(m<gcd):
		gcd = m
print(gcd)

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

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

Solution (Python):
from fractions import gcd

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

for i,item in enumerate(a):
    if i != 0:
        ans = gcd(ans,item)

print(ans,end='')

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

def main():
    n = int(input())
    nums = list(map(int, input().split()))
    print(reduce(gcd, nums))
    
if __name__ == '__main__':
    main()

Solution (Python):
from functools import reduce
N = int(input())
A = list(map(int, input().split()))

def gcd(A, B):
    P = max(A, B)
    Q = min(A, B)
    while P%Q!=0:
        R = P%Q
        P = Q
        Q = R
    return Q

ans = reduce(gcd, A)
print(ans)

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

from functools import reduce
import fractions 


A.sort(reverse = True)

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

print(gcd_list(A))

Solution (Python):



from fractions import gcd
from functools import reduce


def solve(string):
    n, *a = map(int, string.split())
    return str(reduce(gcd, a))


if __name__ == '__main__':
    print(solve("\n".join([input(), input()])))

Solution (Python):



from fractions import gcd
from functools import reduce


def solve(string):
    n, *a = map(int, string.split())
    return str(reduce(gcd, a))


if __name__ == '__main__':
    print(solve("\n".join([input(), input()])))

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

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

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

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

b = min(A)
for a in A:
    while True:
        if a%b == 0:
            break
        tb = b
        b = a%b
        a = tb

print(b)

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

n = int(input())
A = [int(i) for i in input().split()]
for i in range(n - 1):
    A[i + 1] = gcd(A[i], A[i + 1])
    
print(A[-1])

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

while len(a) > 1:
  ans = min(a)
  a = [ai % ans for ai in a if ai % ans != 0]
  a.append(ans)
print(ans)

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

i = 0
while i < len(A) - 1:
    a, b = A[i], A[i + 1]
    A[i] = b % a
    A[i + 1] = a
    if A[i] == 0:
        i += 1
print(A[i])

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

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

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

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

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

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

ans = li[0]

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

print(ans)

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

def main():
  N = int(input())
  a = list(map(int, input().split()))
  r = a[0]
  
  for i in range(1, len(a)):
    r = gcd(r, a[i])
    if r == 1:
      break

  print(r)
    

if __name__ == '__main__':
  main()

Solution (Python):


n=input()
A=map(int, raw_input().split(" "))
A.sort()
last=-1
ans=A[0]

while True:
    if last==ans:
        break
    last=ans
    for a in A:
        m=a%ans
        if m!=0:
            ans=min(m,ans)

print(ans)

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

N = int(raw_input())

arr = map(int, raw_input().strip().split(' '))

result = arr[0]
for i in xrange(1, len(arr)) : 
    result = gcd(result, arr[i])


print result

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

    b = min(A)
    for a in A:
        while True:
            if a%b == 0:
                break
            a,b = b, a%b
    print(b)

main()

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

b = min(A)
for a in A:
    while True:
        if a%b == 0:
            break
        
        tb = b
        b = a % b
        a = tb
print(b)

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

b = min(A)
for a in A:
    while True:
        if a%b == 0:
            break
        a,b = b, a%b
print(b)

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

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

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

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

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

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

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

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

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

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

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

Solution (Python):
import fractions
from functools import reduce
N = int(input())
A = input().split()
A = [int(i) for i in A]
print(reduce(fractions.gcd,A))

Solution (Python):
import math

def process(number_list):
    left, point = number_list[0], number_list[-2]
    if left == 1:
        print(1)
        return 0
    right = number_list[-1] % left
    number_list.pop(-1)
    if right == 0:
        if len(number_list) == 1:
            print(number_list[0])
            return 0
    else:
        number_list.insert(0, right)
    return number_list

def main():
    num = int(input())
    number_list = list(map(int, input().split()))
    number_list.sort()
    while 1:
        number_list = process(number_list)
        if number_list == 0:
            break


if __name__ == '__main__':
    main()

Solution (Python):
from fractions import gcd

n = int(input())
hp_list = list(map(int,input().split()))
test = hp_list[0]

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

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

Solution (Python):
import fractions
from functools import reduce

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

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

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

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

Solution (Python):
N, = list(map(int, input().split()))
A = list(map(int, input().split()))
b = set(A)
while len(b)>1:
  m = min(b)
  c = set((m,))
  for bi in b:
    if bi%m>0:
      c.add(bi%m)
  b = c
print(list(b)[0])

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 = [int(i) for i in input().split()]

print(reduce(gcd, A))

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):
from functools import reduce

def gcd(a, b):
    x = max(a, b)
    y = min(a, b)
    if x % y == 0:
        return y
    else:
        while x % y != 0:
            z = x % y
            x = y 
            y = z
        else:
            return z

def main():
    _ = input()
    monsters = [int(n) for n in input().split(" ")]
    max_gcd = reduce(gcd, monsters)
    print(max_gcd)

if __name__ == "__main__":
    main()

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
A.sort()
count =0
while(len(A)!=1):
    tmp_min_A = min(A)
    for i in range(1,len(A)):
        A[i] = A[i] % tmp_min_A
        if A[i] == 0:
            count +=1
    A.sort()
    for i in range(count):
        A.remove(0)
    count = 0
    
  
print(A[0])

Solution (Python):
from collections import Counter

def parse_line(line, type=int):
	return [type(x) for x in line.split(' ')]


def euklide(a, b):
	while a and b:
		if a > b:
			a = a % b
		else:
			b = b % a
	return a + b


def main():
	n = parse_line(input())[0]
	numbers = parse_line(input())

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

	print(a)



	

if __name__ == '__main__':
	main()

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

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

ans = A[0]

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

print(ans)

Solution (Python):
class MathAlgorithm(object):
    @classmethod
    def gcd(cls, a: int, b: int) -> int:
        if b < 0 or (a == 0 and b == 0):
            raise ValueError

        if b > a:
            return cls.gcd(b, a)

        if b == 0:
            return 0

        if a % b == 0:
            return b

        return cls.gcd(b, a % b)


if __name__ == "__main__":
    N = int(input())
    A = [int(i) for i in input().split()]

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

    print(ans)

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

Solution (Python):



def main(array):
	
	mini = min(array)
	newarray = [mini]
	if mini ==1:
		return 1
	else:
		for a in array:
			if a%mini > 0:
				newarray.append(a%mini)
		if len(newarray) == 1:
			return mini
		else:
			return main(newarray)


n = input()
array = input().split(' ')
array = [int(c) for c in array]

print(main(array))

Solution (Python):


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

def gcd_array(someArray) :
    result = someArray[0]
    for i in someArray[1:] :
        result = gcd(i, result)
    return result

N = int(input())
AList = input().split(" ")
AList = [int(i) for i in AList]
AList.sort()
print(gcd_array(AList))

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

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

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

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

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

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

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

    print(ans)

main()

Solution (Python):
import fractions
from functools import reduce


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

ans = reduce(fractions.gcd, A)
print(ans)

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


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


ans = a[0]

for i in a:
    x = gcd(ans, i)
    if x < ans:
        ans = x


print(ans)

Solution (Python):
def Gcd(a,b):
    if a < b:
        return Gcd(b,a)
    else:
        if a%b:
            return Gcd(b,a%b)
        else:
            return b

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

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

Solution (Python):
n=int(input())
m=list(map(int,input().split()))
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a
ans=m[0]
for i in range(n):
    ans=gcd(ans,m[i])
print(ans)

Solution (Python):






import numpy as np





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





sorted_A = np.sort(np.array(A))





while len(sorted_A) != 1:
    tmp = sorted_A[1:] % sorted_A[0]
    sorted_A = np.sort(np.append(sorted_A[0], tmp[np.nonzero(tmp)[0]]))
print(sorted_A[0])

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

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

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

Solution (Python):
import sys

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

def main():
  input = sys.stdin.readline
  N = int(input())
  A = list(map(int, input().split()))
  ans = A[0]
  for a in A:
    ans = gcd(ans, a)
  print(ans)


if __name__ == '__main__':
  main()

Solution (Python):

import fractions
from functools import reduce

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

N = int(input())
lst_monsters = map(int, input().split())
print(gcd_list(lst_monsters))

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

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

while 1 < len(a):
    while 0 != a[0]:
        r = a[1] % a[0]
        a[1] = a[0]
        a[0] = r
    a.pop(0)
print(a[0])

Solution (Python):

from sys import stdin


s_in = lambda: stdin.readline()[:-1]  
d_in = lambda: int(stdin.readline())  
ds_in = lambda: list(map(int, stdin.readline().split()))  


def gcd(a, b):
    """ Greatest Common Divisor(最大公約数) """
    while b:
        a, b = b, a % b
    return a


N = d_in()
A_list = ds_in()

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

Solution (Python):
def gcd(a, b):
    a = max(a,b)
    b = min(a,b)
    r = a - b
    while(r):
        a = max(b,r)
        b = min(b,r)
        r = a % b
    return b    

N = int(input())
HPs = list(map(int, input().split(' ')))

HPs.sort()

r = HPs[0]
for i in range(1,N):
  r = gcd(HPs[i],r)

print(r)

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

a.sort()
a[0], a[len(a)-1] = a[len(a)-1], a[0]

while a != sorted(a):
  a.sort()
  for i in range(len(a)):
    if a[i] % a[0] == 0:
      a[i] = a[0]
    else:
      a[i] = a[i] % a[0]

print(a[0])

Solution (Python):
N=int(input())
A=list(map(int,input().split()))
a=min(A)
S={n%a for n in A if n%a!=0}

while len(S)>0:
    tmp=a
    a=min(S)
    S={n%a for n in S if n%a!=0}
    if tmp%a!=0:
        S.add(tmp%a)
print(a)

Solution (Python):
import functools
import fractions
N = int(input())
monster = [int(i) for i in input().split()]
print(abs(functools.reduce(fractions.gcd,monster)))

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()))



ans = min(gcd(a[0], x) for x in a)

print(ans)

Solution (Python):



from functools import reduce
from fractions import gcd
input()
print(reduce(gcd, map(int, input().split())))

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



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

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

result = 10 ** 9 + 1

print(gcd(*monsters))

Solution (Python):
import fractions
from functools import reduce

def gcd(numbers):
    return reduce(fractions.gcd, numbers)
N=input()
print(gcd(list(map(int, input().split()))))

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

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

def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)
        
a = A[0]
for i in range(N):
    a = gcd(a,A[i])

print(a)

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


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

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

print( ans )

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

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

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

print(ans)

Solution (Python):

import sys
from functools import reduce

def gcd(n, m):
    if n > m: 
        n, m = m, n
    o = m % n
    if o == 0:
        return n
    else:
        m = n
        n = o
        return gcd(n, m)

def gcds(ns):
    return reduce(gcd, ns)

def solve(N: int, A: "List[int]"):
    print(gcds(A))
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    A = [ int(next(tokens)) for _ in range(N) ]  
    solve(N, A)

if __name__ == '__main__':
    main()

Solution (Python):

import sys
from functools import reduce

def gcd(n, m):
    if n > m: 
        n, m = m, n
    o = m % n
    if o == 0:
        return n
    else:
        m = n
        n = o
        return gcd(n, m)

def gcds(ns):
    return reduce(gcd, ns)

def solve(N: int, A: "List[int]"):
    """
    [思考]
    体力最小のものを Amin とおく．
    すると，試行の結果体力が Amin より小さくなる可能性がある場合はそれが答え，さもなくば Amin が答え．
    問題はその可能性をどう探索するか．
    """
    print(gcds(A))
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    A = [ int(next(tokens)) for _ in range(N) ]  
    solve(N, A)

if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
mons = list(map(int,input().split()))
def gcd(a,b):
    if a == 0:
        return b
    return gcd(b%a,a)
result = mons[0]
for i in range(n-1):
    result = gcd(result, mons[i+1])
print(result)

Solution (Python):
import math
import sys
from operator import itemgetter
input = sys.stdin.readline











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

N = int(input().rstrip())
As = list(map(int, input().rstrip().split()))

ans = As[0]
for i in As[1:]:
	ans = gcd(ans, i)
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()))
ans = a[0]
for i in range(1, n):
	ans = gcd(ans, a[i])
print(ans)

Solution (Python):
import sys

sys.setrecursionlimit(20000)


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


def gcd(a, b):
    la = max(a, b)
    sm = min(a, b)
    if la % sm == 0:
        return sm
    else:
        return gcd(sm, la - sm)


n = int(input())
A = inpl()
A.sort()
ans = gcd(A[0], A[1])
for a in A:
    ans = gcd(ans, a)
print(ans)

Solution (Python):
import fractions
N =int(input())
M = list(map(int,input().split()))

gcd_result=M[0]
for i in range (N-1):
    before = fractions.gcd(gcd_result,M[i+1])
    gcd_result=before
print(gcd_result)

Solution (Python):
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
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)

Solution (Python):
import fractions

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

ans = a[0]

for i in range(1,n):
    ans = fractions.gcd(ans,a[i])

print(ans)

Solution (Python):

n = int(input())


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

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

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

print(ans)

Solution (Python):





def gcd(small,big):
	if big < small:
		big,small = small,big
	if small == 0:
		return big
	else:
		return gcd(big % small,small)

def solveProblem(PowerGauge):
	nowGcd = 0
	for i in range(0,len(PowerGauge),+1):
		nowGcd = gcd(nowGcd,PowerGauge[i])
	answer = nowGcd
	return answer


if __name__ == '__main__':
	_ = int(input().strip())
	An = list(map(int,input().strip().split(' ')))
	solution = solveProblem(An)
	print("{}".format(solution))

Solution (Python):
n = int(input())
a = [int(i) for i in input().split()]
def gcd(x,y):
 if x%y: return gcd(y,x%y)
 else: return y
m = a[0]
for i in range(n): m = gcd(m,a[i])
print(m)

Solution (Python):
def get_int(): return int(input())
def get_float(): return float(input())
def get_line(): return input().split()
def get_lines(v): return [get_line() for _ in range(v)]
def get_int_line(): return list(map(int, get_line()))
def get_int_lines(v): return [get_int_line() for _ in range(v)]
def get_float_line(): return list(map(float, get_line()))
def get_float_lines(v): return [get_float_line() for _ in range(v)]

import functools
import math

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


N = get_int()
A = get_int_line()

print(functools.reduce(gcd, A))

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

Solution (Python):
import fractions
n=int(input())
s = list(map(int,input().split(" ")))
g=s[0]
for i in range(1,n):
  a=fractions.gcd(g,s[i])
  if a<g:
    g=a
print(g)

Solution (Python):
import numpy as np

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
  
n=int(input())
data=list(map(int,input().split()))

tmp=data[0]
for i in range(n-1):
  tmp=gcd(tmp,data[i+1])
  
print(tmp)

Solution (Python):
from fractions import gcd 


n = int(input())
l = list(map(int, input().split()))
num = 0
for i in range(len(l)):
    num = gcd(num, l[i])

print(num)

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

Solution (Python):
import fractions


n = int(input())
l = list(map(int, input().split()))
num = 0
for i in range(len(l)):
    num = fractions.gcd(num, l[i])

print(num)

Solution (Python):
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(input())
l = list(map(int, input().split()))
num = 0
for i in range(len(l)):
    num = gcd(num, l[i])

print(num)

Solution (Python):
def euclid(a, b):
    r = a % b
    while r != 0:
        a = b
        b = r
        r = a % b
    return b

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

min_g = 10 ** 9 + 1
for n in range(N-1):
    g = euclid(a_list[n], a_list[n+1])
    min_g = min(min_g, g)

print(min_g)