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

import math

def gcd_list(nums):
  gcd = nums[0]
  for i in range(1,len(nums)):
    gcd = math.gcd(gcd,nums[i])
  return gcd

print(gcd_list(A))

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

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

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

print(ans)

Solution (Python):
from math 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):
import math
from functools import reduce

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

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

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

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

g = A[0]

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

Solution (Python):
import math

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

ans = 10**10
for i in range(1, n):
    ans = min(ans, math.gcd(a[0], a[i]))
print(ans)

Solution (Python):
from math import gcd
n = int(input())
alst = list(map(int, input().split()))
ans = alst[0]
for a in alst:
  ans = gcd(ans, a)
print(ans)

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

Solution (Python):

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


ans = functools.reduce(math.gcd,A)
print(ans)

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

Solution (Python):





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

def gcd(x, y):
    if x < y:
        t = x
        x = y
        y = t

    if y == 0:
        return x

    else:
        return gcd(y, x % y)

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

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

print(a)

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

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

import math

temp = al[0]

for i in range(1,n):
    temp = math.gcd(temp,al[i])
    
print(temp)

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

    while True:
        currentmin = 10**10
        currentminIndex = 0
        for i in range(n):
            if currentmin > a[i] and a[i] != 0:
                currentmin = a[i]
                currentminIndex = i
        for i in range(n):
            if i != currentminIndex:
                a[i] = a[i] % currentmin
        count = 0
        for i in range(n):
            if a[i] != 0:
                count += 1
        if count == 1:
            break

    print(max(a))


if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
A_list = [float('inf')] * N

ans = min(A)
while max(A_list) > 0:
    mi = ans
    for i,a in enumerate(A):
        amari = a % mi
        A_list[i] = amari
        if amari != 0:
            ans = min(ans,amari)

print(ans)

Solution (Python):
from math import gcd

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

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

print(g)

Solution (Python):
import math

def main():
    _ = input()
    A = list(map(int, input().split()))
    ans = A[0]
    for a in A[1:]:
        ans = math.gcd(ans, a)
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):



import sys
from math import gcd

N = int(input())

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

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

print(ans)

Solution (Python):

"""
Created on Mon Sep 14 17:37:26 2020

@author: liang
"""
N = int(input())
A = [int(x) for x in input().split()]

from math import gcd

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

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

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

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

print(gcd(a))

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

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

Solution (Python):
import math

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

ans = math.gcd(A[0],A[1])
for i in range(2,n):
    ans = math.gcd(ans, A[i])
    
print(ans)

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

Solution (Python):

import sys
import math
import decimal
import itertools
from itertools import product
from functools import reduce
def input():
    return sys.stdin.readline()[:-1]
def sort_zip(a:list, b:list):
    z = zip(a, b)
    z = sorted(z)
    a, b = zip(*z)
    a = list(a)
    b = list(b)
    return a, b

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

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

    print(gcd(*A))

if __name__ == '__main__':
    main()

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

Solution (Python):
from math import gcd

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

Solution (Python):
import numpy as np

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

gcd = np.frompyfunc(np.gcd,2,1)

print(gcd.reduce(a))

Solution (Python):
import numpy as np
from functools import reduce
_ = input()
print(reduce(np.gcd, map(int,input().split())))

Solution (Python):
import numpy as np

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

ans = a[0]

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

print(ans)

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


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

tmp = gcd(l[0],l[1])
for i in range(2,len(l)):
    tmp = gcd(tmp,l[i])

print(tmp)

Solution (Python):
import math

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

for a in A[1:]:
    ans = math.gcd(ans, a)
print(ans)

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

a.sort()

def mod():
    for i in range(1, len(a)):
        
        
        
        
        if(a[i] % a[0] != 0):
            a[i] = a[i] % a[0]
        else:
            a[i] = a[0]
        
    a.sort()
    return a





while(a.count(a[0]) != len(a)):
    a = mod()
    

print(a[0])

Solution (Python):
import math
from functools import reduce

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

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

Solution (Python):
from math import *

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):
from math import gcd
n = int(input())
a = list(map(int,input().split()))
ans = a[0]
for i in a[1:]:
    ans = gcd(ans,i)
print(ans)

Solution (Python):
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right 
from heapq import heapify, heappop, heappush
from itertools import combinations, permutations, product
from math import *

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x):
        self.setdefault(x,0)
        self[x] += 1

N,A = ilint()




from functools import reduce
def lgcd(l):
    return reduce(gcd, l)
print(lgcd(A))

Solution (Python):
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right 
from heapq import heapify, heappop, heappush
from itertools import combinations, permutations, product
from math import *

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x):
        self.setdefault(x,0)
        self[x] += 1

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

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

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

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


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

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

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

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

print(ans)

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

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

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

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

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
m = min(A)
n = 0
while m != n:
    m = min(A)
    a = [m]
    for i in A:
        i %= m
        if i != 0:
            a.append(i)
    A = a
    n = min(A)
print(n)

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

Solution (Python):
def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort()
    before = A
    after = []
    for _ in range(pow(10, 9)):
        x = before[0]
        if len(before) == 1:
            print(x)
            return
        after.append(x)
        for i in range(1, len(before)):
            y = before[i]%x
            if y != 0:
                after.append(y)
        after.sort()
        before = after
        after = []

if __name__ == "__main__":
    main()

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

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

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

def gcd(x,y):
    if y > x:
        x,y = y,x
    if x%y == 0:
        return y
    else:
        return gcd(y,x%y)
        
from functools import reduce
ans = reduce(gcd,L)
print(ans)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
if max(a) != min(a):
    while a.count(0) != len(a)-1:
        a.sort()
        b = [a[0]]
        for i in a[1:]:
            if i%a[0] != 0:
                b.append(i%a[0])
        a = b
    print(max(a))
else:
    print(a[0])

Solution (Python):
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    from functools import reduce
    def gcd(*numbers):
        return reduce(math.gcd, numbers)
    n = I()
    lst = LI()
    ans = gcd(*lst)
    print(ans)
main()

Solution (Python):
import math

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

print(ans)

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

def gcd(nums):
    return functools.reduce(euclid, nums)



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

print(gcd(a))

Solution (Python):
import math

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

ans = math.gcd(al[0], al[1])

for i in range(2, n):
    ans = math.gcd(ans, al[i])

print(ans)

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

print(reduce(math.gcd, A))

Solution (Python):
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 math
from functools import reduce

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

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

Solution (Python):
import sys
import math


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n = inint()
A = inintl()

m = min(A)

mod_min = 10**9

for a in A:
    if a % m == 0:
        continue
    mod_min = min(mod_min, a % m)

if mod_min == 10**9:
    print(m)
else:
    print(math.gcd(m, mod_min))

Solution (Python):
from fractions import gcd
from functools import reduce
N = input()

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

print(reduce(gcd, List))

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

Solution (Python):


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

ans = A[0]
for a in A[1:]:
    if ans > a:
        ans, a = a, ans  
    while a % ans != 0:
        a = a % ans
        a, ans = ans, a
    if ans == 1:
        print(1)
        quit()

print(ans)

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

g = A[0]
import math
for i in range(1, N):
    g = math.gcd(g, A[i])

print(g)

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

x = a[0]
for i in range(1,n):
    x,y = max(x,a[i]),min(x,a[i])
    while y!=0:x,y=y,x%y
print(x)

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

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

x = a[0]
for i in range(1,n):
    y = a[i]
    x,y = max(x,y),min(x,y)
    while y!= 0:
        x,y = y,x%y
print(x)

Solution (Python):
N=int(input())
mns=list(map(int,input().split()))
atk=min(mns)
while 1:
    mns=list(filter(lambda x: x!=0, map(lambda x: x%atk, mns)))
    if not mns:
        break
    mns+=[atk]
    atk=min(mns)
print(atk)

Solution (Python):
import math
from functools import reduce

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

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

print(gcd_list(l))

Solution (Python):
from math import floor, ceil, sqrt, factorial, log, gcd
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict
from heapq import heappop, heappush, heappushpop
import sys
INF = float('inf')
mod = 10**9+7


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





def LI(): return list(map(int, sys.stdin.buffer.readline().split()))




def I(): return int(sys.stdin.buffer.readline())





def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()




def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')







def IR(n): return [I() for i in range(n)]







def LIR(n): return [LI() for i in range(n)]







def SR(n): return [S() for i in range(n)]







def LSR(n): return [LS() for i in range(n)]







def SRL(n): return [list(S()) for i in range(n)]


def main():
    n = I()
    lst = LI()
    ans = lst[0]
    for i in range(1, n):
        ans = gcd(ans, lst[i])
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):

import math
from functools import reduce

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

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

print(gcd_list(a))

Solution (Python):
import math

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

Solution (Python):

from math import gcd
from functools import reduce

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

print(reduce(gcd, X))

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

print(reduce(math.gcd, A))

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

Solution (Python):
from math import gcd

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

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

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

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

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

Solution (Python):
import sys
import heapq

input = sys.stdin.readline


def main():
    N = int(input())
    A = list(map(int, input().split()))
    heapq.heapify(A)
    while True:
        m1 = heapq.heappop(A)
        try:
            m2 = heapq.heappop(A)
        except IndexError:
            print(m1)
            break
        m2 %= m1
        heapq.heappush(A, m1)
        if m2 > 0:
            heapq.heappush(A, m2)


if __name__ == '__main__':
    main()

Solution (Python):
from math import gcd

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


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

Solution (Python):
from math import *
n=int(input())
l=list(map(int,input().split()))
g=l[0]
for i in range(1,n):
    g=gcd(g,l[i])
print(g)

Solution (Python):
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
sys.setrecursionlimit(500*500)
import itertools
from collections import Counter,deque

def main():
    n = int(input())
    l = list(map(int, input().split()))
    k = l[0]
    for i in range(1,n):
        k = gcd(k,l[i])
    print(k)


if __name__=="__main__":
    main(
    )

Solution (Python):
import math 
from functools import reduce

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

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

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

n = int(input())
a = [int(i) for i in input().split()]
if 1 in a:
    ans = 1
else:
    ans = gcd_list(a)
print(ans)

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

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

Solution (Python):
from math import gcd
def readinput():
    n=int(input())
    a=list(map(int,input().split()))
    return n,a

def main(n,a):
    ans=gcd(a[0],a[1])
    for i in range(2,n):
        ans=gcd(ans,a[i])
    return ans

if __name__=='__main__':
    n,a=readinput()
    ans=main(n,a)
    print(ans)

Solution (Python):
from math import gcd


def lgcd(l):
    res = l[0]
    for i in range(1, len(l)):
        res = gcd(res, l[i])

    return res


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

Solution (Python):
def gcd(x, y):
    if(y > x):
        tmp = y
        y = x
        x = tmp

    while(int(x%y)>0):
        r = x%y
        x = y
        y = r

    return y
        


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

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

print(ans)

Solution (Python):
from heapq import heappop,heappush
N = int(input())
A = list(map(lambda x: -1*int(x),input().split()))

now = -1 * heappop(A)
while(A):
    next = -1 * heappop(A)
    if now % next != 0:
        heappush(A,-1*(now%next))
    now = next
print(now)

Solution (Python):
import math
from functools import reduce

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

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

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

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

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

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

print(g)

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

import math
g = math.gcd(a[0], a[1])
for i in range(2, n):
    g = math.gcd(g, a[i])

print(g)

Solution (Python):
import sys
from math import gcd
from functools import reduce

readline = sys.stdin.buffer.readline


def main():
    N = int(readline())
    A = map(int, readline().split())

    print(reduce(gcd, A))
    return


if __name__ == '__main__':
    main()

Solution (Python):
import sys
from math import gcd
from functools import reduce

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *A = map(int, read().split())

    print(reduce(gcd, A))
    return


if __name__ == '__main__':
    main()

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

ans=10**10
for i in range(n-1):
    GCD=math.gcd(a[i],a[i+1])
    if ans>GCD:
        ans=GCD
print(ans)

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

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


n = int(input())

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

print(reduce(gcd, A))

Solution (Python):
import math
from functools import reduce

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


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

answer = gcd(*A)
print(answer)

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
input = sys.stdin.readline

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

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

print(ans)

Solution (Python):
import math

n = int(input())
aL = sorted(list(map(int, input().split(" "))))

ans = aL[0]
for a in aL:
    ans = min(math.gcd(aL[0], a), ans)

print(ans)

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

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

d = a[0]

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

print(d)

Solution (Python):
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]




from functools import reduce


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

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

N = ii()
A = li()

print(gcd_list(A))

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

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

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

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

Solution (Python):
from math import gcd
N = int(input())
A = list(map(int, input().split()))
k = 0
for i in A:
  k = gcd(i,k)
print(k)

Solution (Python):
import math
N = int(input())
A = list(map(lambda a: int(a), input().split(" ")))

gcd = A[0]
for i in range(len(A)):
  gcd = math.gcd(gcd, A[i])
  
print(gcd)

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())
As = list(map(int, input().split()))

from math import gcd
g = 0
for a in As:
	g = gcd(g, a)
print(g)

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

import math

g = math.gcd(A[0], A[0])
for a in A:
    g = math.gcd(g, a)
print(g)

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

while len(A) > 1:
    A.append(gcd(A.pop(), A.pop()))
print(A[0])

Solution (Python):

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

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

print(ans)

Solution (Python):
from math import gcd
N = int(input())
A = list(map(int,input().split()))
ans = 0
for a in A:
    ans = gcd(ans, a)
print(ans)

Solution (Python):
N,*A = map(int,open(0).read().split())
A.sort()
B = [[] for i in range(100)]
B[0]= A

for i in range(99):
  B[i+1].append(B[i][0])
  for j in range(1,len(B[i])):
    x = B[i][j]%B[i][0]
    if x!=0:
      B[i+1].append(x)
  B[i+1]=sorted(B[i+1])
  if len(B[i])<=1:
    break
print(B[i][0])

Solution (Python):
import math

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

res = math.gcd(a[0], a[1])

for x in a:
   res = math.gcd(res, x)

print(res)

Solution (Python):
import math

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

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

print(ans)

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

Solution (Python):
import fractions
n,*a=map(int,open(0).read().split())
e=fractions.gcd(a[0],a[1])
for i in range(1,n):
    e=fractions.gcd(e,a[i])

print(e)

Solution (Python):
import math

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

ans = nums[0]
for n in nums[1:]:
    ans = math.gcd(ans, n)
print(ans)

Solution (Python):
from math import gcd
N = int(input())
A = list(map(int, input().split()))
for i, a in enumerate(A):
  if i == 0:
    g = a
    continue
  g = gcd(g, a)
print(g)

Solution (Python):
import math
import collections
import fractions
import itertools
import functools
import operator
import bisect

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

if __name__ == "__main__":
    solve()

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

import math
from functools import reduce
def gcd_list(numbers):
    return reduce(math.gcd, numbers)
print(gcd_list(a))

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

Solution (Python):
import math
from functools import reduce


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

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

Solution (Python):
from functools import reduce
import math
def main():
    n = int(input())
    A = list(map(int, input().split()))
    print(reduce(math.gcd, A))

if __name__ == '__main__':
    main()

Solution (Python):

import sys
from math import gcd
from itertools import product
def inpl(): return list(map(int, input().split()))

N = int(input())
A = inpl()
a = A[0]
for b in A[1:]:
    a = gcd(a, b)
print(a)

Solution (Python):
import sys

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

def solve():
    input = sys.stdin.readline
    N = int(input())
    A = [int(i) for i in input().split()]
    gcdA = A[0]
    for a in A: gcdA = gcd(gcdA, a)
    print(gcdA)

    return 0

if __name__ == "__main__":
    solve()

Solution (Python):
from math import gcd

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

Solution (Python):
import sys


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def get_min_without_0(A):
    A = [a for a in A if a != 0]
    return min(A)


def attack(A):
    a = get_min_without_0(A)
    A.remove(a)
    return list(map(lambda x: x % a, A)) + [a]


def check(A):
    cnt = 0
    for a in A:
        if a == 0:
            cnt += 1
    if cnt == len(A) - 1:
        return False
    else:
        return True


def main():
    n = ni()
    A = nl()

    while check(A):
        A = attack(A)
    print(max(A))


if __name__ == '__main__':
    main()

Solution (Python):
from math import gcd
N = int(input())
A = tuple(map(int, input().split()))
ans = A[0]
for a in A[1:]:
    ans = gcd(ans, a)
print(ans)