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 sys import stdin
input = stdin.readline
lmi = lambda: list(map(int, input().split()))
mi = lambda: map(int, input().split())
si = lambda: input().strip('\n')
ssi = lambda: input().strip('\n').split()


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


n = int(input())
arr = lmi()
for i in range(1, n):
    arr[i] = gcd(arr[i], arr[i-1])
print(arr[n-1])

Solution (Python):
from sys import stdin

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

N = int(stdin.readline())
A = list(map(int,stdin.readline().strip().split()))

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

print(ans)

Solution (Python):
from sys import stdin
import numpy as np

import fractions as math


N = int(stdin.readline())
A = list(map(int,stdin.readline().strip().split()))

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

print(ans)

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

if __name__ == '__main__':
    N = int(input())
    nums = [int(n) for n in input().split()]
    if len(nums) == 1:
        print(nums[0])
        exit()

    ret = gcd(nums[0], nums[1])
    for n in nums[1:]:
        ret = gcd(ret, n)
    print(ret)

Solution (Python):

from functools import reduce
from fractions import gcd


def main():
    N, *A = map(int, open(0).read().split())
    ans = reduce(gcd, A)
    print(ans)


if __name__ == "__main__":
    main()

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):
def gcd(x,y):
    if x<y:
        x,y=y,x
    if y==0:
        return x
    else:
        return gcd(y,x%y)       
n=int(input())
a=list(map(int,input().split()))
ans=a[0]
for i in range(1,n):
    ans=gcd(a[i],a[i-1])
    a[i]=ans
print(ans)

Solution (Python):
def solve():
    n = int(input())
    A = [int(s) for s in input().split()]
    ans = A[0]
    for i in range(1,n):
        ans = gcd(A[i], ans)
    return ans

def gcd(a,b):
    a,b = max(a,b), min(a,b)
    while b > 0:
        a,b = b,a%b
    return a
    
if __name__ == '__main__':
    print(solve())

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()))
ans = max(A)
def gcd(x, y):
  if y == 0:
    return x
  else:
    return gcd(y, x % y) 

for i in range (0,N-1):
  x = gcd(A[i],A[i+1])
  ans = min(ans,x)
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, len(a)):
    ans = gcd(ans, a[i])
    
print(ans)

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


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


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


print(gcd_for_arr(a))

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

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

Solution (Python):
from functools import reduce
def gcd(a, b):
    if b==0:
        return a
    while b>0:
        a, b = b, a%b
    return a

N = int(input())
A = map(int, input().split())
ans = reduce(gcd, A)
print(ans)

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

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

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

a = list(map(int,input().split()))
back=0
back2=1
while back != back2:
  while 0 in a:a.remove(0)
  x=min(a)  
  t=a.index(x)
  for i in range(len(a)):
    a[i] = a[i] % x
  a[t]=x
  back2=back
  back=x

print(x)

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):
from heapq import heapify, heappop, heappush
N = int(input())
A = [int(i) for i in input().split()]
heapify(A)
while len(A) > 1:
    curr_attacker, curr_attacked = heappop(A), heappop(A)
    if curr_attacked % curr_attacker != 0:
        heappush(A, curr_attacked % curr_attacker)
    heappush(A, curr_attacker)
print(A[0])

Solution (Python):
from fractions import gcd

N = int(input())
A = list(map(int,input().split()))
ans = A[0]
for i in A[1:]:
    ans = gcd(ans,i)
    if ans ==1:
        break
print(ans)

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):
from fractions import gcd
N = int(input())
A = list(map(int,input().split()))
ans = 0
for i in range(len(A)):
    ans = gcd(A[i],ans)
print(ans)

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

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

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

Solution (Python):
import fractions
from functools import reduce

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

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

print(gcd_list(List))

Solution (Python):
n = int(input())
a = [int(x) for x in input().split()]
while True:
    a.sort()
    b = [i % a[0] for i in a[1:]]
    b.insert(0, a[0])
    b = [i for i in b if i != 0]
    if len(b) == 1: break
    else: a = b
print(b[0])

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




while len(set(A)) >= 2:
    A = list(set(A))
    min_A = min(A)
    A = [x%min_A if x%min_A != 0 else min_A for x in A]
    
print(A[0])

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

while True:
    A.sort()
    t = sum(A)
    for i in range(1, N):
        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()))

a=min(A)
ans=0
l=[]

def gcd(lis,num):
    temp=[]
    for item in lis:
        if num%item!=0:
            pass
        else:
            temp.append(item)
    return temp

for i in range(1,int(a**0.5)//1+1):
    if a%i==0:
        l.append(i)
        l.append(a//i)

for item in A:
    l=gcd(l,item)

print(max(l))

Solution (Python):
def slove():
    import sys
    import fractions
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    a = list(map(int, input().rstrip('\n').split()))
    gcd = 0
    for i in range(n):
        gcd = fractions.gcd(gcd, a[i])
    print(gcd)


if __name__ == '__main__':
    slove()

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

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

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


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


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

print(gcd_list(A))

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

import fractions
from functools import reduce

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

Solution (Python):
from fractions import gcd
from math import ceil,floor,sqrt
n = int(input())
a = list(map(int, input().split()))

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

Solution (Python):

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

def result(monstar, n): 
	new = s(monstar[0], monstar[1]) 
	for i in range(2, n): 
		new = s(new,monstar[i]) 
	return new

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

Solution (Python):

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

def result(monstar_h, n): 
	new = s(monstar_h[0], monstar_h[1]) 
	for i in range(2, n): 
		new = s(new,monstar_h[i]) 
	return new

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

Solution (Python):
n = int(input())
A = list(map(int,input().split()))
count = 1
while count>0:
    count=0
    mod = min(A)
    for i in range(n):
        if A[i]==mod:
            continue
        elif A[i]%mod ==0:
            A[i]=mod
            count +=1
        else:
            A[i] = A[i]%mod
            count +=1
print(A[0])

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

def gcd_list(L):
    b=min(L)
    for i in L:
        while True:
            if i%b==0:
                break
            c=b
            b=i%b
            i=c
    return(b)

print(gcd_list(A))

Solution (Python):
import sys
from bisect import *
from collections import *
from copy import deepcopy
from datetime import *
from heapq import *
from itertools import *

from operator import *
from pprint import *

sys.setrecursionlimit(10**8)

input = sys.stdin.readline

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

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

if __name__ == '__main__':
    main()

Solution (Python):
def calculate(a, b):
    if a < b :
        a, b = b, a
    
    while b > 0:
        a, b = b, a%b

    return a

N = int(input())
A_list = list(map(int, input().split()))
gcd_num = A_list[0]
for i in range(1, N):
    gcd_num = calculate(gcd_num, A_list[i])
print(gcd_num)

Solution (Python):
def calculate(a, b):
    if a < b :
        a, b = b, a
    
    while b > 0:
        a, b = b, a%b

    return a

N = int(input())
A_list = list(map(int, input().split()))
gcd_num = A_list[0]
for i in range(1, N):
    gcd_num = calculate(gcd_num, A_list[i])
print(gcd_num)

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

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

Solution (Python):
from collections import deque

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

while len(A)>1:
    a=A.popleft()
    for _ in range(len(A)):
        aa=A.popleft()
        if aa%a>0:
            A.append(aa%a)
    A.append(a)

print(A[0])

Solution (Python):
from collections import deque

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

while len(A)>1:
    a=A.popleft()
    for _ in range(len(A)):
        aa=A.popleft()
        if aa%a>0:
            A.append(aa%a)
    A.append(a)

print(A[0])

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=10**10
for i,j in zip(a,a[1:]):
    ans=min(ans,gcd(i,j))
print(ans)

Solution (Python):
import fractions 

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

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

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

Solution (Python):
import fractions

n = int(input())
x = list(map(int,input().split()))
res = fractions.gcd(x[0],x[1])

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

print(res)

Solution (Python):
import sys 
stdin = sys.stdin
ns = lambda : stdin.readline().rstrip()
ni = lambda : int(ns())
na = lambda : map(int, stdin.readline().split())

n = ni()
a = list(na())

def gcd(n, m):
  while m:
    n, m = m, n%m
  return n

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

Solution (Python):

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

Solution (Python):
import sys, fractions
sys.setrecursionlimit(5 * 10**5)
input = sys.stdin.readline

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 fractions
n = int(input())
A = list(map(int, input().split()))
min_A = min(A)
B = []
for i in range(n):
  B.append(A[i]%min_A)
if all(B[i] == 0 for i in range(n)):
  print(min_A)
else:
  m = A[0]
  for i in range(1,n):
    m = fractions.gcd(m, A[i])
  print(m)

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

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

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

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

A.sort()

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

    A.sort()

print(A[0])

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

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

mini = min(A)
div = 10**9
for a in A:
    div = min(div,gcd(mini,a))

print(div)

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

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

v=a[0]
for i in range(1,n):
  v=lcd(v,a[i])

print(v)

Solution (Python):
from functools import reduce
from fractions import gcd
import sys
input = sys.stdin.readline


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


if __name__ == '__main__':
    main()

Solution (Python):
from functools import reduce
from fractions import gcd
import sys
input = sys.stdin.readline


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


if __name__ == '__main__':
    main()

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

Solution (Python):

import fractions

n = int(input().split()[0])
n = int(n)

hp_list = list(map(int, input().split()))
hp_list = [int(hp) for hp in hp_list]

hp = hp_list[0]

for h in hp_list[1:]:
    hp = fractions.gcd(hp, h)

print(hp)

Solution (Python):
import fractions
n=int(input())
lists=list(map(int,input().split()))
gcds=lists[0]
for x in range(n-1):
    if n==0:
        gcds=fractions.gcd(lists[0],lists[1])
    else:
        add=fractions.gcd(lists[x],lists[x+1])
        gcds=fractions.gcd(gcds,add)
print(gcds)

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(1, N):
    ans = gcd(ans, A[i])

print(ans)

Solution (Python):
import heapq

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

heapq.heapify(A)
flag = True

while flag:
    minA = heapq.heappop(A) 
    if len(A) == 0: 
        break
    if minA == 0: 
        continue
    A = list(map(lambda x: x % minA, A))
    heapq.heappush(A, minA)

print(minA)

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

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

ans = A.pop()
while A:
  ans = gcd(ans, A.pop())
print (ans)

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

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

import fractions

ans = a[0]

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

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

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

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

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

def Ans(ans):
    lst = []
    small = min(ans)
    for i in ans:
        if i%small != 0:
            lst.append(i%small)
    lst.append(small)
    if len(lst) == 1:
        print(lst[0])
    else:
        ans = lst
        Ans(ans)
Ans(A)

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

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

Solution (Python):
from heapq import heapify, heappop, heappush

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

while len(a) > 1:
    a1, a2 = heappop(a), heappop(a)
    m = a2 % a1
    heappush(a, a1)
    if m:
        heappush(a, m)
print(heappop(a))

Solution (Python):
import fractions
n = int(input())
l = [int(i) for i in input().split()]
ans = l[0]
for i in range(n):
    ans = fractions.gcd(ans,l[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):
from functools import reduce
from fractions import gcd

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

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

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):
import numpy as np
N=int(input())
A=np.array(list(map(int, input().split())))
A=np.sort(A)
while A.shape[0]>1:
  A[1:]%=A[0]
  A=A[A>0]
  A=np.sort(A)
print(A[0])

Solution (Python):

N=int(input())
a=list(map(int, input().split()))
import fractions
ans = a[0]
for i in range(1, N):
    ans = fractions.gcd(ans, a[i])
    if ans==1:
        break
print(ans)

Solution (Python):

N=int(input())
A=list(map(int, input().split()))
B=min(A)
i=0
n=1
while i<N:
    a=A[i]%B
    i+=1
    if 0<a<B:
        B=a
        i=0
    elif 0<a:
        i-=1
        A[i]=a
    elif B==1:
        break
print(B)

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())
array = list(map(int, input().split()))
array.sort()
min = array[0]
while True:
	tmp2 = min
	for item in array:
		tmp = item % min
		if tmp != 0 and tmp < min:
			min = tmp
	if min == tmp2:
		break
print(min)

Solution (Python):
import fractions

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


if __name__ == "__main__":
    test()

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 fractions

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

cm = A[0]

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

print(cm)

Solution (Python):

import sys
input = sys.stdin.readline
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7


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):
def gcd(x,y):
    if x<y:
        x,y = y,x
    while y>0:
        x,y = y,x%y
    return x
N = int(input())
A = list(map(int,input().split()))
x = A[0]
for i in range(1,N):
    y = A[i]
    x = gcd(x,y)
print(x)

Solution (Python):
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=sys.stdin.readline
def resolve():
    n=int(input())
    A=map(int,input().split())
    from fractions import gcd
    from functools import reduce
    print(reduce(gcd,A))
resolve()

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

from fractions import gcd
n = int(input())
a = list(map(int,input().split()))
ans = 10**10

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

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

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

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

Solution (Python):
N=int(input())
A=list(map(int, input().split()))
f=A[0]
g=A[1]
while f%g!=0:
  f,g=[g, f%g]
for i in range(2,N):
  f=A[i]
  while f%g!=0:
    f,g=[g, f%g]
print(g)

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(n-2):
    g = gcd(g,a[i+2])
print(g)

Solution (Python):
from fractions import gcd

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

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

print(a)

Solution (Python):
import numpy as np

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

B = list(set(A))
B.sort()
C = np.asarray(B)

while(len(C)>1):
    t = C[0]
    C = np.append(C[1:]%t,t)
    C = list(set(C))
    C.sort()
    if C[0]==0:
        C = np.asarray(C[1:])
    else:
        C = np.asarray(C)

print(C[0])

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

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

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

print(g)

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):
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):
from fractions import gcd

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

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

Solution (Python):
if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split()))
    A.sort()
    mod = A[0]
    flag = True
    while flag:
        for i in range(0, N):
            if A[i]%mod == 0:
                if i == N -1:
                    flag = False
                continue
            else:
                mod = A[i]%mod
                A[i] = mod
                break 
    print(mod)

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 fractions
N=int(input())
A=[int(x) for x in input().split()]
ans=A[0]
for a in A[1:]:
  ans=fractions.gcd(ans,a)
print(ans)

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

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

Solution (Python):
import fractions

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

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

print(res)

Solution (Python):



import heapq

N = int(input())
a = list(map(int, input().split()))
heapq.heapify(a)
tmp = 0
tmp2 = 0

for i in range(pow(10,5)):
    tmp = heapq.heappop(a)
    if tmp == 1:
        print(tmp)
        exit()
    a = list(map(lambda x: x % tmp, a))
    if sum(a) == 0:
        print(tmp)
        exit()
    else:
        a = [j for j in a if j != 0]
        heapq.heappush(a, tmp)

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

def GCD(n):
	return reduce(gcd, n)

input()
print(GCD(list(map(int, input().split()))))

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

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

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

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

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

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

while len(a) > 1:
    for i in range(1, len(a)):
        a[i] %= a[0]
    a = sorted(set(a))

    if a[0] == 0:
        a = a[1::]

print(*a)

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):
def MAP(): return list(map(int,input().split()))
import fractions

n = int(input())
A = MAP()

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

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

def resolve():
    n = int(input())
    aaa = list(map(int ,input().split()))
    print(gcd_list(aaa))
resolve()

Solution (Python):
import sys
readline = sys.stdin.readline
n = int(readline())
a = list(map(int, readline().split()))
a.sort()

zero_count = 0
curr = 0
i = 0

while n - zero_count > 1:
    
    if i != curr and a[i] != 0:
        if a[i] % a[curr] == 0:
            a[i] = 0
        elif a[curr] <= a[i]:
            a[i] = a[i] % a[curr]
            if a[i] < a[curr]:
                curr = i
        if a[i] == 0:
            zero_count += 1
    if i == n - 1:
      i = 0
    else:
      i += 1

print(max(a))

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

Solution (Python):
N = int(input())
As = list(map(int, input().split()))
def calcgcd(a, b):
  if a > b:
    a, b = b, a
  while a > 0:
    a, b = b%a, a
  return b
r = 0
for A in As:
  r = calcgcd(r, A)
print(r)

Solution (Python):
from fractions import gcd


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

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


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


res = nums[0]
for x in nums[1:]:
    res = gcd(res, x)

print(res)

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

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

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


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

Solution (Python):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate
import sys



def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LIM(): return list(map(lambda x:int(x) - 1, sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def LIRM(n): return [LIM() 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)]
mod = 1000000007


n = I()
nums = LI()


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


ret = nums[0]
while len(nums) > 1:
    ret = gcd(ret, nums.pop(-1))



print(ret)

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

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

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

print(res_1)

Solution (Python):
import fractions
from functools import reduce

N = int(input())
A = list(map(int,input().split()))
print(reduce(lambda a, b: fractions.gcd(a,b), A))

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

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

while len(alist) > 1:
  min_a = min(alist)
  alist.remove(min_a)
  new_alist = [min_a]
  for a in alist:
    if int(a%min_a) != 0:
      new_alist.append(int(a%min_a))
  alist = copy.deepcopy(new_alist)

print(new_alist[0])

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

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

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

accum_gcd = A[0]
for i in range(n):
    accum_gcd = gcd(accum_gcd,A[i])
print(accum_gcd)

Solution (Python):
import fractions

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

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

Solution (Python):
from fractions import gcd

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

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

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

def Gcd(*numbers):
  return reduce(gcd, numbers)
N = int(input())
ls = [int(i) for i in input().split()]

print(Gcd(*ls))

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

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()))
A.sort()

def gcd(x, y):
	while y:
		x, y = y, x % y
	return x
 
ans = gcd(A[0],A[1])
for i in range(2,n):
  ans = gcd(ans,A[i])
print(ans)