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



Sample input:
4
2 10 8 40


Sample output:
2

Submission status: Runtime Error

Solution code:
import math

n = int(input())
a = [int(x) for x in input().split(" ")]
g = a.sort()[n - 1]

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

Submission status: Runtime Error

Solution code:
import math

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

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

Submission status: Runtime Error

Solution code:
import math

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

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

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

N = input()
line = list(map(int,input().split()))
ans = gcd_list(line)

print(ans)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

N = int(input())
line = list(map(int,input().split()))
ans = gcd_list(line)

print(ans)

Submission status: Runtime Error

Solution code:
import math
n = int(input())
A = list(map(int, input().split()))

A.sort()
j = 0

while j == 0:
    a = math.gcd(A[0], A[1])
    A.append(a)
    A.sort()
    if A[0] == A[1] :
        j = 1

print(A[0])

Submission status: Runtime Error

Solution code:
from itertools import combinations
N=int(input())
A=list(map(int,input().split()))
#Ai以下の値になる組み合わせの総和と余り
list_sum_c = []
ans = 0
for a in A:
    temp_A = [temp_a for temp_a in A if temp_a != a]
    for k in range(1,len(A)):#ピックアップする値の数
        comb = list(combinations(temp_A, k))
        for c in comb:
            sum_c = sum(c)
            if sum_c < a:
                if a%sum_c==0:
                    list_sum_c.append(sum_c)
                else:
                    ans = a%sum_c

min_sum_c = min(list_sum_c)
if ans > min_sum_c:
    ans = min_sum_c
print(ans)

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10000)

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

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
from math import *
from functools import *

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

Submission status: Runtime Error

Solution code:
from fraction import gcd
from functools import reduce

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

print(reduce(gcd, an))

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

print(reduce(math.gcd, an))

Submission status: Runtime Error

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

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

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

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

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

Submission status: Runtime Error

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

#B
"""
n, m = map(int, input().split())
ans = input().split()
del ans[0]
for i in range(n-1):
    a = input().split()
    del a[0]
    for k in ans:
        if k in a:
            continue
        else:
            ans.remove(k)
    if len(ans) == 0:
        break
print(len(ans))
"""
#C
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()))
print(gcd_list(a))

Submission status: Runtime Error

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

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

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

Submission status: Runtime Error

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

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

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

Submission status: Runtime Error

Solution code:
import math

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

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

print(ans,end='')

Submission status: Runtime Error

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

from functools import reduce
import fraction 


A.sort(reverse = True)

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

print(gcd_list(A))

Submission status: Runtime Error

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

from functools import reduce
import math 


A.sort(reverse = True)

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

print(gcd_list(A))

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from math import gcd
from functools import reduce


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


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

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from math import gcd
from functools import reduce


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


if __name__ == '__main__':
    print(solve("4\n2 10 8 40"))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math

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

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

Submission status: Runtime Error

Solution code:
import math
from functools import reduce
#入力
N = map(int,input().strip().split(' '))         #モンスタ数
A = list(map(int, input().strip().split(' '))) #それぞれの体力


#最大公約数
print( reduce(lambda x, y: math.gcd(x,y), A) )

Submission status: Runtime Error

Solution code:
import math
from functools import reduce
#入力
N = map(int,input().strip().split(' '))         #モンスタ数
A = list(map(int, input().strip().split(' '))) #それぞれの体力


#最大公約数
print( reduce(lambda x, y: math.gcd(x,y), A) )

#PASS (lambda A[i], A[i-1] :math.gcd(A[i],A[i-1]), A))

Submission status: Runtime Error

Solution code:
from functools import reduce
from functools import gcd

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

print(reduce(gcd, A))

Submission status: Runtime Error

Solution code:
from functools import reduce
import math

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

if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N = int(input())
As = list(map(int,input().split()))
while True:
  minnum = As.index(min(As))
  if len(As) <= 1 or As[minnum] == 1:
  print(As[minnum])
  break
  for i in range(len(As)):
    if not i == minnum:
      As[i] -= As[minnum] 
      if As[i] < 0:
        As[i] = 0
  while True:
    if 0 in As:
      As.remove(0)
    else:
      break

Submission status: Runtime Error

Solution code:
import functools
import math

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

# 最大公約数
ans = functools.reduce(math.gcd, a)
print(ans)

Submission status: Runtime Error

Solution code:
def Gcd(a,b):
	if a<b:
		return Gcd(b,a)
	else:
		if a%b:
			return Gcd(b, a%b):
		else:
			return b
N = int(input())
arr = list(map(int,input().split()))
gcd = arr[0]
for i in arr:
	gcd = Gcd(gcd, i)
print(gcd)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = int(input())
lst_a = list(map(int, input().split()))

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

ans = lst_a[0]
for a in lst_a:
    # 配列の最初からひとつずつ最大公約数を取っていけばよい。
    ans = gcd(ans, a)

print(ans)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

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

Submission status: Runtime Error

Solution code:
N = int(input())
lst_monsters = map(int, input().split())

import math
from functools import reduce
# def gcd(*lst):
#     return reduce(math.gcd, lst)

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

ans = gcd_list(lst_monsters)
print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())
lst_monsters = map(int, input().split())

import math
from functools import reduce

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

ans = gcd_list(lst_monsters)
print(ans)

Submission status: Runtime Error

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

from functools import reduce
import math

R = reduce(math.gcd,A)

print(int(R))

Submission status: Runtime Error

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

from functools import reduce
import math

R = reduce(math.gcd,A)

print(R)

Submission status: Runtime Error

Solution code:
import math
import itertools
# print(math.gcd(1000000000, 1000000000))

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

result = 10 ** 9 + 1

for comb in list(itertools.combinations(monsters,2)):
    gcd = math.gcd(comb[0], comb[1]) 
    if gcd < result:
        result = gcd

print(result)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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


N = int(input())

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

print(gcd(A))

Submission status: Runtime Error

Solution code:
n=int(input())

def euc(a,b):
  if a==b:
    return a
  else:
    return euc(max(a,b)%min(a,b),min(a,b))
ans=0
mons=list(map(int,input().split()))
for i in range(n-1):
  p=euc(mons[i],mons[i+1])
  if p==1:
    ans=1
    break
    
  else:
    mons[i+1]=p

if ans==1:
  print(1)
else:
  print(mons[n-1])

Submission status: Runtime Error

Solution code:
n=int(input())

def euc(a,b):
  if a==b:
    return a
  else:
    return euc(max(a,b)-min(a,b),min(a,b))
ans=0
mons=list(map(int,input().split()))
for i in range(n-1):
  p=euc(mons[i],mons[i+1])
  if p==1:
    ans=1
    break
    
  else:
    mons[i+1]=p

if ans==1:
  print(1)
else:
  print(mons[n-1])

Submission status: Runtime Error

Solution code:
n=int(input())

def euc(a,b):
  if a==b:
    return a
  else:
    return euc(max(a,b)-min(a,b),min(a,b))

mons=list(map(int,input().split()))
for i in range(n-1):
  p=euc(mons[i],mons[i+1])
  if p==1:
    ans=1
    break
    
  else:
    mons[i+1]=p

if ans==1:
  print(1)
else:
  print(mons[n-1])

Submission status: Runtime Error

Solution code:
N=int(input())
A=map(int,input().split())
ans=A[0]
for i in range(1,N):
  s=ans
  t=A[i]
  if t%ans!=0:
    s=t%ans
  t=A[i]
  if ans%t!=0:
    t=t%ans
  ans=min(s,t)
print(ans)

Submission status: Runtime Error

Solution code:
n=int(input())

def euc(a,b):
  if a==b:
    return a
  else:
    return euc(max(a,b)-min(a,b),min(a,b))

mons=list(map(int,input().split()))
for i in range(n-1):
  p=euc(mons[i],mons[i+1])
  if p==1:
    ans=1
    break
  else:
    mons[i+1]=p

if ans==1:
  print(1)
else:
  print(mons[n-1])

Submission status: Runtime Error

Solution code:
import math
import sys
import random
from operator import itemgetter
input = sys.stdin.readline

# a = int(input().rstrip())
# a, b = map(int, input().rstrip().split())
# D = list(map(int, input().rstrip().split()))
# H = [int(input().rstrip()) for _ in range(L)]
# DD = [[0 for j in range(100)] for i in range(200)]
# dict = {} ## dictionary

# a = sorted(a, key=lambda x: x[1]))
# if __name__ == '__main__':

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

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

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

n = int(input())
hp = [int(j) for j in input().split()]
print(gcd_list(hp))

Submission status: Runtime Error

Solution code:
import sys

sys.setrecursionlimit(20000)


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


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


n = int(input())
A = inpl()

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

Submission status: Runtime Error

Solution code:
import sys

sys.setrecursionlimit(2000)


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


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


n = int(input())
A = inpl()

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

Submission status: Runtime Error

Solution code:
import random

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

while True:
	a = m.pop(random.randrange(n)); n -= 1
	b = m.pop(random.randrange(n)); n -= 1
	a -= b
	m.extend([a, b]); n += 2
	print(m)
	for i in m:
		if i <= 0:
			m.remove(i); n -= 1
	if len(m) == 1: print(m[0]); exit()

Submission status: Runtime Error

Solution code:
import sys

sys.setrecursionlimit(2000)


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


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


n = int(input())
A = inpl()

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

Submission status: Runtime Error

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


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


n = int(input())
A = inpl()

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

Submission status: Runtime Error

Solution code:
import math
N =int(input())
M = list(map(int,input().split()))

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import fraction

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

ans = a[0]

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

print(ans)

Submission status: Runtime Error

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

N = get_int()
A = get_int_line()

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

Submission status: Runtime Error

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

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

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

print(ans)

Submission status: Runtime Error

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

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

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

    print(ans)

Submission status: Runtime Error

Solution code:
# _*_ coding:utf-8 _*_
#  Atcoder_Beginners_Contest118-C
#  https://atcoder.jp/contests/abc118/tasks/abc118_c
#  ref https://note.nkmk.me/python-gcd-lcm/
import math
from functools import reduce

def gcdList(lists):
	allGcd = reduce(math.gcd,lists)
	return allGcd

def solveProblem(PowerGauge):
	answer = gcdList(PowerGauge)
	return answer


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

Submission status: Runtime Error

Solution code:
import math

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

print(gcd)

Submission status: Runtime Error

Solution code:
def gcd(a,b):
 
    if a>=b:
        #print(a,b)
    # max_ab = max(a,b)
    # min_ab = (a+b)-max_ab
        amari = a % b
        if amari == 0:
            #print(b)
            # if b==1:
            #     return 
            # else:
            return b
        else:
            #print(amari)
            gcd(b,amari)
           
    else:
        #print(a,b)
        amari = b % a
        if amari == 0:
            return a
        else:
            #print(amari)
            gcd(a,amari)
           

N = int(input())
list_m = list(map(int, input().split()))
num = gcd(list_m[0],list_m[1])
if num==None:
    num = 1
    
#print(num)
if N>2:
    for i in range(N-2):
        num = gcd(num,list_m[i+2])
        #print(num)


print(num)

Submission status: Runtime Error

Solution code:
import numpy as np
import math
import sys
from functools import reduce

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

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

print(gcd(*a))

Submission status: Runtime Error

Solution code:
#abc118c

import functools
import math

n=int(input())
l=list(map(int,input().split()))
print(functools.reduce(math.gcd,l))

Submission status: Runtime Error

Solution code:
from math import gcd
n = int(input())
arr = sorted(list(map(int, input().split(' '))))
maxi = arr[-1]
gc = maxi
for num in arr[:-1]:
    if gcd(num, maxi) < gc:
        gc = gcd(num, maxi)

print(gc)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math
N = int(input())
a = list(map(int, input().split()))

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

print(a[N-1])

Submission status: Runtime Error

Solution code:
import math
N = int(input())
a = list(map(int, input().split()))

for i in range(N - 1):
    a[i + 1] = int(math.gcd(a[i], a[i+1]))

print(a[N-1])

Submission status: Runtime Error

Solution code:
import math
N = int(input())
a = list(map(int, input().split()))

for i in range(N - 1):
    a[i + 1] = int(math.gcd(a[i], a[i+1]))
    print(a)

print(a[N-1])

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math
import itertools
import numpy as np
import sys
input = sys.stdin.readline
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
A = IL()

ans = math.gcd(A[0],A[1])
for i in A:
  if i%ans != 0:
    ans = math.gcd(ans,i)
  if ans == 1:
    break

print(ans)

Submission status: Runtime Error

Solution code:
from math import gcd

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

Submission status: Runtime Error

Solution code:
from fractions import gcd
n=int(input())
a=list(map(int,input().split()))
print(gcd(a))

Submission status: Runtime Error

Solution code:
from fractions import gcd
n=int(input())
a=list(map,input().split())
print(gcd(a))

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)
  
n=int(input())
a=list(map(int,input().split()))
ans=gcd(a[0],a[1])
if n>2:
  for i in range(2,n):
    ans=gcd(ans,a[i])
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math
from functools import reduce
def gcd(numbers):
    return reduce(math.gcd, numbers)

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

Submission status: Runtime Error

Solution code:
from fraction import gcd
from functools import reduce
n = int(input())
print(reduce(gcd,map(int,input().split())))

Submission status: Runtime Error

Solution code:
N = int(input())
life_list = list(map(int, input().split()))
life_list.sort()
while life_list[1] - life_list[0] > 0:
    if life_list[1] == life_list[0]:
        break
	life_list[1] = life_list[1] - life_list[0]
    life_list.sort()
        
print(life_list[0])

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
ans=0
if m>n*2:
  m-=n*2
  ans=n+m//4
elif m==n*2:
  ans=n
else:
  ans=m//2
print(ans)

Submission status: Runtime Error

Solution code:
from fractions import gcd
from functools import reduce
input()
def gcd(*numbers):
    return reduce(math.gcd, numbers)
print(gcd(*[int(i) for i in input().split()]))

Submission status: Runtime Error

Solution code:
import math
from functools import reduce
input()
def gcd(*numbers):
    return reduce(math.gcd, numbers)
print(gcd(*[int(i) for i in input().split()]))

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(max(int, input().split()))

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

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

print(num)

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int,input().split()))
m = max(a)
while m != min(a):
    m = min(a)
    for i in range(len(a)-1):
        if a[i] != m: a[i] = a[i] % m
        a = list(set(a))
        if 0 in a: a.remove(0)
    #print(a)

print(m)

Submission status: Runtime Error

Solution code:
n = int(input()) 
#n=4
hps = [int(i) for i in input().split()]
#lst = [2, 2, 8, 40]
#lst = [5, 13, 8, 1000000000]
#lst = [0, 1, 0]
    ##2 4 5 -> 1
    ## minと全ての要素のgcd
hps = sorted(hps)
for i in range(1,n):
    hps[0] = gcd(hps[i], hps[0])
#print(hps)
for i in range(len(hps)):
    if(hps[i]==0): continue
    print(hps[i])
    break

Submission status: Runtime Error

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

cand = A[0]
 
for i in range(1,N):
    cand = math.gcd(cand, A[i])
    if cand == 1:
        break
print(cand)

Submission status: Runtime Error

Solution code:
n = int(input())
a = [int(k) for k in input().split()]
import math
ans = math.gcd(a[0],a[1])
for i in a[2:]:
	ans = math.gcd(ans,i)
print(ans)

Submission status: Runtime Error

Solution code:
from functools import reduce
from math import gcd

if __name__ == '__main__':
    n = int(input())
    a = [int(s) for s in input().split()]
    print(reduce(gcd, a))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
from math import gcd
n = int(input())
if n == 1:
    print(input())
else:
    a = [i for i in map(int, input().split())]
    ans = gcd(a[0], a[1])
    if 2 < n:
        for i in a[2:]:
            ans = gcd(ans, i)
    print(ans)

Submission status: Runtime Error

Solution code:
import math
n = int(input())
a_list = list(map(int, input().split()))
num = a_list[0]

for i in range(n):
    num = math.gcd(num, a_list[i])
print(num)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#ABC118C-MonstersBattleRoyale.py

from sys import stdin
from functools import reduce
import math

input = stdin.readline

N = int(input())

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

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#coding:utf-8
N  = int(input())
A = list(map(int,input().split()))
def c(A,B):
    for a,b in zip(A,B):
        if a != b:
            return False
    return True
while True:
    A.sort()
    prev = A[:]
    
    s = A[0]
    for i in range(N):
        if A[i] % s == 0:
            A[i] = s
        else:
            A[i] = A[i] % s
    A.sort()
    #print("A  :",A)
    #print("pre:",prev)
    if  c(prev,A) : break
#print("A  :",A)
#print("pre:",prev)
print(A[0])
#coding:utf-8
N  = int(input())
A = list(map(int,input().split()))
def c(A,B):
    for a,b in zip(A,B):
        if a != b:
            return False
    return True
while True:
    A.sort()
    prev = A[:]
    
    s = A[0]
    for i in range(N):
        if A[i] % s == 0:
            A[i] = s
        else:
            A[i] = A[i] % s
    A.sort()

    if  prev==A : break

print(A[0])

Submission status: Runtime Error

Solution code:
n = int(input())
a_list = list(map(int, input().split()))
num = a_list[0]

for i in range(n):
    num = math.gcd(num, a_list[i])
print(num)

Submission status: Runtime Error

Solution code:
#copy code
from fractions import gcd
n=int(input())
a=[int(i) for i in input().split()]
c=a[0]
for i in a:
    c=gcd(c,a)
print(c)

Submission status: Runtime Error

Solution code:
#ABC118C-MonstersBattleRoyale.py

from sys import stdin
from functools import reduce
import math

input = stdin.readline

N = int(input())

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

print(reduce(math.gcd, A))

Submission status: Runtime Error

Solution code:
def gcd(a, b):
    if a < b:
        a, b = b, a

    if b == 0:
        return a

    c = a % b
    return gcd(b, c)

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

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

print(b)

Submission status: Runtime Error

Solution code:
import math

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

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

print(b)

Submission status: Runtime Error

Solution code:
N = int(input())
hp = map(int,input().split())
hp = sorted(hp)
while True:
    if len(hp) == 1:
        break
    hp[1] = hp[1] - hp[0]
    if hp[1] <= 0:
        hp.pop(1)
    if hp[1]%hp[0] == 0:
        break
    hp = sorted(hp)
print(hp[0])

Submission status: Runtime Error

Solution code:
import math

"""
def gcd(a, b):
    if a < b:
        a, b = b, a

    if b == 0:
        return a

    c = a % b
    return gcd(b, c)
"""

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

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

print(b)

Submission status: Runtime Error

Solution code:
from math import gcd
from functools import reduce

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

n = int(input())

print(gcd_list([int(i) for i in input().split()]))

Submission status: Runtime Error

Solution code:
N=int(input())
A=[int for i in input().split()]
mini=min(A)
while mini>0:
    for i in range(len(A)):
        if A[i]!=mini:
            A[i]=A[i]%mini
    z=A.count(0)
    A=sorted(A)[z:]
    m=A[0]
    if m==1:
        break
    else:
        if [i%m for i in A]==[0]*len(A):
            break
print(A[0])