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):
from fractions import gcd
from functools import reduce
input()
a=list(map(int,input().split()))
print(reduce(gcd,a))

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

ans = A[0]
for i in range(1,N):
    bns = A[i]
    l = max(ans, bns)
    s = min(ans, bns)
    while l % s != 0:
        l, s = s, l % s
    ans = s

print(ans)

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

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

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

A = sorted(A)

ans = min(A)
while(1):
    prev = ans
    B = list(map(lambda x: x % ans , A[1:]))
    A = [ans] + [i for i in B if i != 0]
    ans = min(A)
    if ans == prev:
        print(ans)
        exit(0)
    A = sorted(A)

Solution (Python):
from fractions import gcd

N = int(input())
L = sorted(map(int, input().split()))

memo = []
memo.append(L[0])
for i in range(N):
    memo.append(gcd(memo[-1], L[i]))

print(memo[-1])

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

import fractions 

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

Solution (Python):
import fractions

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

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

print(ans)

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

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

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

Solution (Python):
def main():
    import sys
    input = sys.stdin.readline
    N = int(input())
    A = list(map(int, input().split()))
    from fractions import gcd
    ans = A[0]
    for i in range(1,N):
        ans = gcd(ans,A[i])
        
    print(ans)
    
    
    
    
main()

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


def gcd(a,b):
    if a == b:
        return a
    elif a > b:
        return euclid(a,b)
    elif a < b:
        return euclid(b,a)

    print "error"
    return 0

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

def monsters_battle_royale(n,a):
    _a = sorted(a)
    tmp = _a[0]
    for i in range(n):
        tmp = gcd(tmp,_a[i])

    return tmp
if __name__ == '__main__':
    n = int(raw_input())
    a = map(int,raw_input().split())


    print monsters_battle_royale(n,a)

Solution (Python):
import math
import copy
import sys
import fractions
import numpy as np
from functools import reduce



def getInputInt():
    inputNum = int(input())
    return inputNum

def getInputListInt():
    outputoData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData

def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList

def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList



n, = map(int, input().split())
data = getInputListInt()

tmp = True

while tmp:
    data.sort()

    for i in range(len(data)-1, 0, -1):
        divi = data[i] % data[0]
        if divi == 0:
            data.pop(i)
        else:
            data[i] = divi

    if data[0] == min(data):
        tmp = False

print(data[0])

Solution (Python):

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)


from fractions import gcd

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

def main():
    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)

main()

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

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

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


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

ans = A[0]

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

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
while True:
  a.sort()
  t = sum(a)
  for i in range(1, len(a)):
    if a[i] % a[0] == 0:
      a[i] = a[0]
    else:
      a[i] = a[i] % a[0]
  if sum(a) == t:
    break
print(a[0])

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

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

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

Solution (Python):
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):
def gcd1(x,y):
    while (x % y) != 0:
        x,y = y,x%y
    return y

def Gcd(x,y):
    if x < y:
        _ = x
        x = y
        y = _
    return gcd1(x,y)

N = int(input())
AList = list(map(int,input().split()))
AList.sort(reverse=True)

gcd = Gcd(AList[0],AList[1])
for n in range(2,N):
    gcd = Gcd(gcd,AList[n])

print(gcd)

Solution (Python):
import fractions
import functools


N = int(input())
nums = list(map(int, input().split()))
res = functools.reduce(fractions.gcd, nums)
print(res)

Solution (Python):
import math;

def swap(a,b):
    return (b,a)

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

def main():
    n = int(input())
    A = [x for x in map(int,input().split())]
    ans = A[0]
    for i in range(1,n):
        ans = gcd(ans,A[i])
    print(ans)
    return

if __name__ == '__main__':
    main()

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

Solution (Python):
import fractions
n = int(input())
a = list(map(int, input().split()))
gcd = 0
for i in a:
    gcd = fractions.gcd(gcd, i)
print(gcd)

Solution (Python):
from fractions import gcd
_ = input()
*A, = map(int, input().split())
b = 0
for a in A:
    b =gcd(a, b)
print(b)

Solution (Python):
from fractions import gcd
from functools import reduce
_ = input()
*A, = map(int, input().split())
print(reduce(gcd, A))

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

Solution (Python):
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()))
n = gcd(A)
print(gcd_list(A))

Solution (Python):
from fractions import gcd

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

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
def gcd(x,y):
  while x%y>0:
    x,y=y,x%y
  return y
a.sort(reverse=True)
ans=a[0]
for j in range(n-1):
  ans=gcd(ans,a[j+1])
print(ans)

Solution (Python):
from functools import*
from fractions import*
_,a=open(0)
print(reduce(gcd,map(int,a.split())))

Solution (Python):
from functools import*
d=lambda x,y:d(y%x,x)if y%x else x
_,a=open(0)
print(reduce(d,map(int,a.split())))

Solution (Python):
def main():
    N = int(input())
    A = [int(a) for a in input().split()]
    prev = A[0]
    for i in range(1, len(A)):
        prev = gcd(prev, A[i])
    return prev

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

if __name__ == '__main__':
    print(main())

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

def gcd(p, q):
    if p < q:
        p, q = q, p
    while q > 0:
        p, q = q, p%q
    return p
  
ans = max(a)
for i in range(n):
    ans = gcd(ans, a[i])
print(ans)

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

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


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

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

import sys
import math
from collections import defaultdict


sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]


mod = 10**9 + 7


def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))



import fractions
from functools import reduce

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

N = I()
A = III()

print(gcd_list(A))

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

import fractions
g = 0
for x in a:
  g = fractions.gcd(g,x)
print(g)

Solution (Python):
n = int(input())
monster_list = [ int(v) for v in input().split() ]

def gcd(a,b):
    if a < b:
        a, b = b, a
    while b >= 1:
        a, b = b, a % b
    return a
a = monster_list[0]
for i in range(n-1):
    a = gcd(a,monster_list[i+1])
print(a)

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

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

L.sort()
ans=L[0]
for i in range(n-1):
  ans=gcd(ans,L[i+1])
    

print(ans)

Solution (Python):
import fractions

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

ans=0
aa=a[0]
for i in a:
    ans=fractions.gcd(aa,i)
    aa=ans
print(ans)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
from fractions import gcd
g = gcd(a[0],a[1])

for i in range(2,n):
  g = gcd(a[i], g)
  
print(g)

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

A.sort()


while True:
    flag = False
    _min = min(A)
    for i in range(N):
        if A[i] % _min > 0:
            A[i] %= _min
            flag = True

    if not flag:
        print(min(A))
        exit()

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

n = int(input())
monster = sorted(list(map(int,input().split())))
ans = []
for i in range(n-1):
  g = gcd(monster[i], monster[i+1])
  ans.append(g)
print(min(ans))

Solution (Python):


def gcd(a, b):
    big, small = max(a, b), min(a,b)
    if big % small == 0:
        return small
    return gcd(small, big%small)


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

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

print(ans)

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


def solve():
    n = int(input())
    a = list(map(int, input().split()))
    return reduce(fractions.gcd, a)


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

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

import fractions
from functools import reduce

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

print(gcd_list(As))

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

Solution (Python):
def gcd(a,b):
  c=0
  while True:
    c=a%b
    if 0==c: break
    a,b=b,c
  return b

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

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

a.sort()
x = [a[1],a[0],a[1] % a[0]]
for i in range(1,n):
    while x[2] > 0:
        x[0] = x[1]
        x[1] = x[2]
        x[2] = x[0] % x[1]
    if i != n - 1:
        x[0] = a[i+1]
        x[2] = x[0] % x[1]

print(x[1])

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

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

m = a[0]
for i in a:
    m = min(fractions.gcd(m,i), m)
print(m)

Solution (Python):
n = int(input())
a = list(map(int, input().split(' ')))
min_a = a.pop(a.index(min(a)))
while len(a) != 0:
    a = [x%min_a for x in a if x%min_a != 0]
    a.append(min_a)
    min_a = a.pop(a.index(min(a)))
print(min_a)

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

hp = max(l)

l.sort()

while hp > 1 and len(l) != 1:
    a = l[0]
    for i in range(1, len(l)):
        l[i] %= a
    l.sort()
    while l[0] == 0:
        l.remove(0)
    if l[0] < hp:
        hp = l[0]

print(hp)

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

Solution (Python):
import fractions

n=int(input())
li = list(map(int,input().split()))
an=10**9

for i in range(n-1):
    if fractions.gcd(li[i],li[i+1]) < an:
        an=fractions.gcd(li[i],li[i+1])
    if an==1:
        print(an)
        exit()

print(an)

Solution (Python):
import fractions
n = int(input())
gcd = 0
for i in list(map(int, input().split())):
    gcd = fractions.gcd(gcd, i)
print(gcd)

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

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

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

Solution (Python):
from fractions import gcd

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

print(g)

Solution (Python):
import fractions
from functools import reduce

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

print(reduce((lambda x, y: fractions.gcd(x, y)), a))

Solution (Python):
import fractions
from functools import reduce

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


print(reduce((lambda x, y: fractions.gcd(x, y)), a))

Solution (Python):

def f(a, n):
    b = []
    minA = min(a)
    b.append(minA)
    for i in range(n):
        if a[i] % minA != 0:
           b.append(a[i] % minA)
    if len(b) == 1:
        print(b[0])
        exit()
    else:
        f(b,len(b))

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

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
div = min(a)
flag = 0
while flag == 0:
    for i in range(n):
        if a[i] % div != 0:
            a[i] = a[i] % div
    if div == min(a):
        flag = 1
    else:
        div = min(a)
print(div)

Solution (Python):
import fractions

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

Solution (Python):


from fractions import gcd

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

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

print(res)

Solution (Python):
n = int(input())
aaa = list(map(int, input().split()))
def gcd(a,b):
  if b==0:
    return a
  return gcd(b, a%b)

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

Solution (Python):
import fractions

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

minA = A[0]

for i in A:
    minA = fractions.gcd(minA, i) 

print(minA)

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

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

import fractions

ans = a[0]
for x in a:
    ans = fractions.gcd(ans, x)

print(ans)

Solution (Python):
"""


    = sys.stdin.readline().rstrip()
    = list(sys.stdin.readline().rstrip())


    = int(sys.stdin.readline())
    = map(int, sys.stdin.readline().split())
    = list(map(int, sys.stdin.readline().split()))
    = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  


a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654


char_list = list("abcd") 
"""

import math
import sys
import itertools
import queue
from fractions import gcd

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

mod = 1000000007

if __name__ == "__main__":
    N = int(sys.stdin.readline())
    L = list(map(int, sys.stdin.readline().split()))
    
    while True:
        m = min(L)
        L = [l % m for l in L if l % m != 0]
        L.append(m)
        if min(L) == m:
            print(m)
            exit()

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

while(len(l))>1:
    l=[i%ans for i in l if i%ans!=0]
    l.append(ans)
    ans=min(l, default=ans)
    
print(ans)

Solution (Python):
import fractions
from functools import reduce

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

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

print(gcd_list(a))

Solution (Python):

n = int(input())
a = list(map(int,input().split()))
gcd = a[0]
for i in range(1,n):
  b = gcd
  c = a[i]
  while c != 0:
    d = b % c
    b = c
    c = d
  gcd = b
print(gcd)

Solution (Python):
N = int(input())
A = [0] + list(map(int, input().split()))




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

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

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

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

Solution (Python):
"""


 = sys.stdin.readline().rstrip()
 = list(sys.stdin.readline().rstrip())


 = int(sys.stdin.readline())
 = map(int, sys.stdin.readline().split())
 = list(map(int, sys.stdin.readline().split()))
 = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  


a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654


char_list = list("abcd") 
"""

import math
import sys
import itertools
import queue
from fractions import gcd
from itertools import accumulate
from functools import reduce


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

mod = 1000000007

if __name__ == "__main__":
    n = int(sys.stdin.readline())
    A = list(map(int, sys.stdin.readline().split()))
    print(reduce(gcd,A))

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
def euclidean(a,b):
    cond = 1
    while cond:
        temp = a % b
        if temp == 0:
            return b
        else:
            a = b
            b = temp

lcm = a[0]
for i in range(1,n):
    lcm = euclidean(lcm,a[i])

print(lcm)

Solution (Python):
from functools import reduce

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

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

res = reduce(gcd, xs, xs[0])

print(res)

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

def kouyakusuu(x, y):
    if x < y:
        tmp = y
        y = x
        x = tmp
    elif x == y:
        return x

    while True:
        tmp1 = x // y
        tmp2 = x % y
        if tmp2 == 0:
            return y
        x = y
        y = tmp2

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

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

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

def gcd(a,b):
    if a%b == 0:
        return b
    else:
        return gcd(b,a%b)
    
A.sort()
c = A[0]
for i in range(1,N):
    ans = gcd(A[i],c)
    if ans == 1:
        break
    else:
        c = ans


print(ans)

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

while not(len(monsters) == 1):
    monsters = [monster for monster in monsters if monster != 0]
    minNum = min(monsters)
    ind = monsters.index(min(monsters))
    for i in range(len(monsters)):
        if i != ind:
            monsters[i] = monsters[i] % minNum
print(monsters[0])

Solution (Python):
import sys
import fractions
from collections import deque

input = sys.stdin.readline

N = int(input())
a = [int(x) for x in input().rstrip("\n").split()]
q = deque(a)

while len(q) > 1:
    x = q.popleft()
    y = q.popleft()
    z =  fractions.gcd(x, y)
    q.append(z)

ans = q.popleft()
print(ans)

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

while lst.count(0) != len(lst)-1:
    lst.sort()
    m = None
    for i in range(len(lst)):
        if lst[i]!=0 and m==None:
            m = lst[i]
        elif lst[i]!=0:
            lst[i] %= m
else:
    print(sum(lst))

Solution (Python):
N = int(input().strip())
A = sorted(map(int, input().strip().split()), reverse=True)

ans = A[-1]

l = A[0]
for r in A[1:]:
  if r < l:
    tmp = r
    r = l
    l = tmp
  mod = -1
  while mod != 0:
    div, mod = divmod(l, r)
    l = r
    r = mod

print(l)

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

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

g = a_list[0]
for i in range(1,N):
    g = gcd(g,a_list[i])

print(g)

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

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

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

print(ans)

Solution (Python):
n=int(input())
li=list(map(int,input().split()))
li.sort()
while True:
  if len(li)==1:
    print(li[0]);exit()
  divisor=li[0]
  temp=[li[0]]
  for i in li[1:]:
    if i%divisor:
      temp+=[i%divisor]
  li=sorted(temp)

Solution (Python):
import fractions

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



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

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

print(min_life)

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

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

print(gcd)

Solution (Python):
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac

setrecursionlimit(1000000)


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

def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(l):
	x = l.pop()
	y = l.pop()
	while(x%y!=0):
		z = x%y
		x = y
		y = z
	l.append(min(x,y))
	return gcd(l) if len(l) > 1 else l[0]

class Queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class Stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

main()

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

Solution (Python):


import sys

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

n = int(input())
tmp = input().split()
hoge = list(map(lambda a: int(a), tmp))

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

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


a = int(input())
b = list(map(int, input().split()))
c = 0
for i in b:
    c = g_c_d(c, i)
print(c)

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)

g = a[0]

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

print(g)

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

hp_list = sorted(hp_list)
while (True):
    if hp_list[0] == 1 or len(hp_list) == 1:
        break
    for i in range(1, len(hp_list)):
        if hp_list[i] > hp_list[0]:
            hp_list[i] = hp_list[i] % hp_list[0]
        else:
            hp_list[i] = 0
    hp_list = [u for u in hp_list if u > 0]
    hp_list = sorted(hp_list)
print(hp_list[0])

Solution (Python):
import numpy as np

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

import fractions as frc

for i in range(n-1):
	if i==0:
		res=x[0]
	res=frc.gcd(res,x[i+1])

print(res)

Solution (Python):
import sys
import fractions

sys.setrecursionlimit(10**6)
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def LIST(): return [int(x) for x in input().split()]
MOD = 10**9 + 7

N = INT()

A = LIST()

def gcd_all(n):
    if len(n) == 1:
        return n[0]

    tail = n.pop(-1)
    return fractions.gcd(tail, gcd_all(n))

print(gcd_all(A))

Solution (Python):
import sys
import fractions

sys.setrecursionlimit(10**9)
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def LIST(): return [int(x) for x in input().split()]
MOD = 10**9 + 7

N = INT()

A = LIST()

def gcd_all(n):
    if len(n) == 1:
        return n[0]

    tail = n.pop(-1)
    return fractions.gcd(tail, gcd_all(n))

print(gcd_all(A))

Solution (Python):


import fractions

N = int(input())

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

g = a[0]

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

print(g)

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

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

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

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

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

print(g)

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

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 gcd(x, y):
    while y > 0:
        x, y = y, x % y
    return x

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

print(g)

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

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

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

print(g)

Solution (Python):

n = int(input())
A = sorted([int(el) for el in input().split(' ')])

def attack(B):
    for i in range(1, len(B)):
        B[i] = B[i] % B[0]
    return sorted(B)

while len(A) > 1:
    A = attack(A)
    A = [a for a in A if a > 0]
print(A[0])

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

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

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


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

ans = 10 ** 9
for i in range(n - 1):
    ans = min(ans, gcd(a[i], a[i + 1]))

print(ans)

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

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

Solution (Python):
import bisect
N = int(input())
n_list = list(map(int, input().split()))

n_list.sort()
while(len(n_list) > 1):
    min_n = n_list[0]
    for i in range(1, len(n_list)):
        n_list[i] = n_list[i] % min_n
    n_list.sort()
    index = bisect.bisect(n_list, 0)
    n_list = n_list[index:]
    

print(n_list[0])

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

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

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

print(ans)

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

ans = 0

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

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

print(ans)

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


a = int(input())
b = list(map(int, input().split()))
c = 0
for i in range(a):
    c = g_c_d(c, b[i])
print(c)

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
while True:
    k = min(a)
    i = 0
    while i < len(a):
        if a[i] % k == 0:
            del a[i]
        else:
            a[i] = a[i] % k
            i += 1
    a.append(k)
    if len(a) == 1:
        print(min(a))
        exit()
print(min(a))

Solution (Python):
from fractions import gcd

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

dp = [0] * (N + 1)
dp[0] = AAA[0]

for i, A in enumerate(AAA):
    if i == N:
        break
    dp[i + 1] = gcd(dp[i], A)

print(dp[N])

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)