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:
# coding: utf-8
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = lr()
A = np.array(lr())
g = np.gcd.reduce(A)
print(g)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
def gcdl(l):
    from functools import reduce
    reduce(lambda x, y: gcd(x, y), a)
n=input()
print(gcdl(list(map(int,input().split()))))

Submission status: Runtime Error

Solution code:
import sys
from io import StringIO
import unittest
# from fractions import gcd
from math import gcd
from functools import reduce

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

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

    gcd_num = gcd_list(a)

    print(gcd_num)

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """4
2 10 8 40"""
        output = """2"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """4
5 13 8 1000000000"""
        output = """1"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """3
1000000000 1000000000 1000000000"""
        output = """1000000000"""
        self.assertIO(input, output)

if __name__ == "__main__":
    # unittest.main()
    resolve()

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

n = int(input())
num_list = list(map(int,input().split()))
def gcd_list(numbers):
    return reduce(math.gcd, numbers)

print(gcd_list(num_list))

Submission status: Runtime Error

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

ans = 0

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

print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())

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

t = max(A)

import math

for i in A:
    t = math.gcd(t, i)
print(t)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

import math
from functools import reduce

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

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

print(gcd_list(A))

Submission status: Runtime Error

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

import math
from functools import reduce

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

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

print(gcd_list(A))

Submission status: Runtime Error

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

import math
from functools import reduce

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

print(gcd_list(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:
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:
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)

Submission status: Runtime Error

Solution code:
from math import gcd
# def lcm(x,y):
#   return (x*y)//gcd(x,y)

n=int(input())
a=list(map(int,input().split()))
ans=10**18
t=0
for i in range(1,n):
  if i==1:
    t=gcd(a[i-1],a[i])
    continue
  t=gcd(t,a[i])
  ans=min(t,ans)
print(ans)

Submission status: Runtime Error

Solution code:
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())
x = list(map(int, input().split()))

print(gcd_list(x))

Submission status: Runtime Error

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

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

Submission status: Runtime Error

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

import math
tmp = a[0]
for num in a:
    tmp = math.gcd(tmp, num)           #最大公約数
print(tmp)

Submission status: Runtime Error

Solution code:
import math

N = int(input())

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

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

print(ret)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math
n = int(input())
a = list(map(int,input().split()))
# def lcm(a,b):
#     return(a*b//math.gcd(a,b))
ans = a[0]
for i in range(1,n):
    ans = min(ans,math.gcd(ans,a[i]))
    
print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int,input().split()))
A.sort()
ans = []
def gcd(a,b):
    if b%a == 0:
        return(a)
    else:
        return(gcd(b%a,b))
for i in range(len(A)):
    ans.append(gcd(A[i],A[i+1]))
    A[i+1]=ans[i]
print(min(ans))

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int,input().split()))
A.sort()
ans = []
answ = []
def gcd(a,b):
    if b%a == 0:
        return(a)
    else:
        return(gcd(b%a,b))
for i in range(len(A)-1):
    ans.append(gcd(A[i],A[i+1]))
ans.sort()
for i in range(len(ans)-1):
    answ.append(ans(A[i],A[i+1]))
print(max(answ))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)
n = int(input())
A = sorted(list(map(int, input().split())))
print(gcd(*A))

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
from functools import reduce
from math import gcd

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


print(reduce(gcd,a))

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

print(reduce(math.gcd, A))

Submission status: Runtime Error

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

import math
from functools import reduce

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

print( gcd_list(  a ) )

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

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

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

print( gcd_list(  a ) )

Submission status: Runtime Error

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

ans = 0
min_value = max(list_A)
for s in list_A:
    if s % 2 == 1:
        ans = 1
        break
    if s <= min_value:
        min_value = s
        ans = s
if max(list_A) == min(list_A)
    ans = list_A[0]
print(ans)

Submission status: Runtime Error

Solution code:
from functools import reduce
import fractions 
N = int(input())
L = [i for i in map(int,input().split())]
def gcd_list(numbers):
  return reduce(fractions.gcd(),numbers)
prind(gcd_list(L))

Submission status: Runtime Error

Solution code:
#118c
N = int(input())
A_list = list(input())

import fractions #math
from functools import reduce

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

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

print(gcd_list(A_list))

Submission status: Runtime Error

Solution code:
import heapq

n = int(input())
A = list(map(lambda x: int(x) * (-1), input().split()))

heapq.heapify(A)

while len(A) > 1:
    print(A)
    Amax1 = heapq.heappop(A) * (-1)
    Amax2 = heapq.heappop(A) * (-1)
    pushA = Amax1 % Amax2
    if pushA == 0:
        heapq.heappush(A, Amax2 * (-1))
    else:
        heapq.heappush(A, pushA * (-1))
        heapq.heappush(A, Amax2 * (-1))

print(A[0] * (-1))

Submission status: Runtime Error

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

min_gcd = INF

for a in range(len(lists) - 1):
  min_gcd = min(min_gcd, math.gcd(lists[a], lists[a+1]))

print(min_gcd)

Submission status: Runtime Error

Solution code:
from math import gcd

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

Submission status: Runtime Error

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

B = [A[0]]
for i in range(N):
    if A[i]%A[0] != 0:
        B.append(A[i]%A[0])
B = set(B)
B = sorted(B,reverse = False) 

#import math
import fractions
from functools import reduce

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

print(gcd_list(B))

Submission status: Runtime Error

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

B = [A[0]]
for i in range(N):
    if A[i]%A[0] != 0:
        B.append(A[i]%A[0])
B = set(B)
B = sorted(B,reverse = False) 


import math
from functools import reduce

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

print(gcd_list(B))

Submission status: Runtime Error

Solution code:
n = int(input())

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

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

m = max(A)
if len(A) == 1:
    print(A[0])
else:
    for i in range(n-1):
        for j in range(i+1, n):
            m = min(m, gcd(A[i], A[j]))
    print(m)

Submission status: Runtime Error

Solution code:
n = int(input())

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

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
    
m = max(A)
if len(A) == 1:
    print(A[0])
else:
    for i in range(n):
        for j in range(i+1, n):
            m = min(m, gcd(A[i], A[j]))
    print(m)

Submission status: Runtime Error

Solution code:
import math

n = int(input())
a = [int(i) for i in input().split()]
mn1 = min(a)
a.remove(mn1)
mn2 = min(a)
ko = math.gcd(mn2,mn1)
print(ko)

Submission status: Runtime Error

Solution code:
def kouyaku(m,n):
    mn = min(m,n)
    risuto = []
    for i in range(2,mn+1):
        if m%i==0 and n%i==0:
            risuto.append(i)
    return max(risuto)

n = int(input())
a = [int(i) for i in input().split()]
mn1 = min(a)
a.remove(mn1)
mn2 = min(a)
ko = kouyaku(mn2,mn1)
if ko > 1:
    print(ko)
else:
    print(1)

Submission status: Runtime Error

Solution code:
from fractions import gcd
from functools import reduce
input()
print(reduce(gcd,map(input().split())))

Submission status: Runtime Error

Solution code:
import math
from functools import reduce
def gcdl(numbers):
    return reduce(math.gcd, numbers)
n=int(input())
a=list(map(int,input().split()))
print(gcdl(a))

Submission status: Runtime Error

Solution code:
import fractions

def monsters_battle_royal(n, a):
    gcd = a[0]
    for i in range(1, n):
        gcd = fractions.gcd(gcd, a[i])
    return gcd

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

ans = monsters_battle_royal(n, a)
print(ans)

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,len(a)):
    ans = math.gcd(ans,a[i])


print(ans)

Submission status: Runtime Error

Solution code:
import math

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

print(math.gcd(monster[0], monster[1]))

Submission status: Runtime Error

Solution code:
import math
from functools import reduce


N = int(input())
A = [int(i) for i in input().split()]
print(reduce(math.gcd, A))

Submission status: Runtime Error

Solution code:
import sys
import math
f = sys.stdin
n = int(f.readline())
a = list(map(int, f.readline().split()))
a.sort()
gcd = math.gcd(a[0], a[1])
print(gcd)

Submission status: Runtime Error

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

import math

gcd_a = A[0]

for i in A:
    gcd_a = math.gcd(gcd_a,i)

print(gcd_a)

Submission status: Runtime Error

Solution code:
import math

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

Submission status: Runtime Error

Solution code:
import math

N = int(input())
A = [int(i) for i in 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:
# coding: utf-8
# Your code here!
import fractions
from functools import reduce
def pin(type=int):
    return map(type,input().split())


N, =pin()
m = list(pin())




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

print(gcd_list(m))

Submission status: Runtime Error

Solution code:
# coding: utf-8
# Your code here!
def pin(type=int):
    return map(type,input().split())


N, =pin()
m = list(pin())

import math
from functools import reduce


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

print(gcd_list(m))

Submission status: Runtime Error

Solution code:
from fractions import gcd
from functools import reduce

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

print(reduce(gcd,A))

Submission status: Runtime Error

Solution code:
from fractions import gcd
from functools import reduce

N=int(input())
A=[int(input()) for _ in range(N)]

print(reduce(gcd,A))

Submission status: Runtime Error

Solution code:
from math import gcd

N = int(input())
A = sorted([int(n) for n in input().split()], reverse=True)

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

Submission status: Runtime Error

Solution code:
# 解説読んでやり方理解した
from math import gcd
from functools import reduce


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


def main():
    N = int(input())
    monsters = list(map(int, input().split(" ")))
    print(get_gcd(monsters))


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
#from scipy.misc import comb

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:
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
#from scipy.misc import comb

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

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

print(ans)

Submission status: Runtime Error

Solution code:
import functools
import math

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

max_koyaku_num = functools.reduce(math.gcd, a)

print(max_koyaku_num)

Submission status: Runtime Error

Solution code:
import functools
import math

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

max_koyaku_num = functools.reduce(math.gcd, a)  #最大公約数って英語でなんて言うん？

print(max_koyaku_num)

Submission status: Runtime Error

Solution code:
import fractions 

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

ans = 0
for i in range(N):
  if i == 0:
    ans = A[0]
    continue

  ans = gcd(ans,A[i])
  
print(ans)

Submission status: Runtime Error

Solution code:
n=int(input())
a=list(map(int,input().split()))
def solve():
    a=sorted(a)
    ans=a[0]#暫定最小

    if len(set(a))!=1:
        for _ in range(a[0]):
            for i in range(n):
                amari=a[i]%ans
                
                if amari>0:
                    if amari<ans:
                        ans=amari
            if ans==1:
                break
    print(ans)

solve()

Submission status: Runtime Error

Solution code:
n=int(input())
a=list(map(int,input().split()))
a=sorted(a)
ans=a[0]#暫定最小

amari=[ans]
if len(set(a))!=1:
    for _ in range(a[0]):
        for i in range(n):
            if a[i]%ans>0:
                amari+=[a[i]%ans]
            ans=min(amari)
    if ans==1:
        break
print(ans)

Submission status: Runtime Error

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

def a_gcd(t,y):
    return math.gcd(t,y)

if m1==1:
    print(m1)
    exit()
for i in range(n):
    m1=a_gcd(m1,a[i])
    if m1==1:
        break

print(m1)

Submission status: Runtime Error

Solution code:
import sys
import math
import itertools
stdin = sys.stdin
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

n = ni()
a = na()

ans = a[0]

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

Submission status: Runtime Error

Solution code:
# ABC118c
from fractions import gcd
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

n = int(input())
a = list(map(int, input().split()))
#from functools import reduce


def gcds(*numbers):
    return reduce(gcd, numbers)


print(gcds(a))
exit(0)


def solve(l):
    m = min(l)
    nl = list()
    for i in l:
        if i % m != 0:
            nl.append(i % m)
    nl.append(m)
    # print(nl)
    if len(nl) == 1:
        return m
    return solve(nl)


print(solve(a))

Submission status: Runtime Error

Solution code:
n = int(input())

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

from fractions import gcd
m = max(A)
if len(A) == 1:
    print(A[0])
else:
    for i in range(n):
        for j in range(i+1, n):
            m = min(m, gcd(A[i], A[j]))
    print(m)

Submission status: Runtime Error

Solution code:
n = int(input())

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

from fractions import gcd
m = max(A)
for i in range(n):
    for j in range(i+1, n):
        m = min(m, gcd(A[i], A[j]))
print(m)

Submission status: Runtime Error

Solution code:
import fraction

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n=int(input())
a=list(map(int,input().split()))
while len(a)>1:
    s=min(a)
    a = list(map(lambda x:x-min(a), a))
    a = [i for i in a if i != 0]+[s]
print(int(a))

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

Submission status: Runtime Error

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np
N = int(input())
A = [int(x) for x in readline().rstrip().split()]
A = np.array(A, np.int64)
while len(A) > 1:
    A = A[np.nonzero(A)]
    A = np.sort(A)
    minA = A[0]
    A %= minA
    A[0] = minA
A = A[np.nonzero(A)]
print(A[0])

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N = int(input())
A = [int(i) for i in input().split()]
A = set(A)
 
min1 = min(A)
A.remove(min1)
min2 = min(A)
if len(A) == 1:
  print(A.pop())
  exit()
 
is_all_even = True
 
for x in A:
  if x % 2 == 1:
    is_all_even = False
    break
    
if is_all_even or min2 % min1 == 0:
  print(min(A))
else:
  print(1)

Submission status: Runtime Error

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

if len(A) == 1:
  print(A.pop())
  exit()

min1 = min(A)
A.remove(min1)
min2 = min(A)

while True:
  min3 = min(A)
  A.remove(min3)
  if min3 % 2 == 1:
    break 
  
while True:
  tmp1 = min1
  min1 = min2 % min1
  min2 = tmp1
  
  tmp2 = min3
  min3 = min2 % min3
  min2 = tmp2
  if min1 == 0:
    min1 = tmp1
    min3 = tmp2
    break
  if min1 == 1:
    break
    
print(min(min1, min3))

Submission status: Runtime Error

Solution code:
n=int(input())
a=list(map(int,input().split()))
import math
mini=float('inf')
for i in range(n-1):
    x=math.gcd(a[i],a[i+1])
    mini=min(mini,x)
print(mini)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
print(reduce(math.gcd, a))

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
print(reduce(math.gcd, *a))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
from functools import reduce
from math import gcd

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

Submission status: Runtime Error

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

d = deque(A)
ans = d[0]
while d:
    l = d.popleft()
    r = d.popleft()
    a = r % l
    if a == 0:
        d.appendleft(l)
    elif a == 1:
        ans = 1
        break
    else:
        ans = min(ans, a)
        d.appendleft(r)
        d.appendleft(a)
print(ans)

Submission status: Runtime Error

Solution code:
import fractions

# N個の最大公約数
# ユークリッド互除法


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


def my(A):
    A = sorted(A)

    while True:
        v = A[0]
        tmp = [v]
        for i in range(len(A)):
            if A[i] % v == 1:
                print(1)
                return
            if A[i] % v == 0:
                pass
            else:
                tmp.append(A[i] % v)

        if len(A) == 1:
            print(A[0])
            return

        A = sorted(tmp)
        # print(A)


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

    good(A)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
from fractions import gcd
from functools import reduce

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

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

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

print(gcd_list(list_aaa))

Submission status: Runtime Error

Solution code:
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())
list_aaa = list(map(int,input().split()))

print(gcd_list(list_aaa))

Submission status: Runtime Error

Solution code:
import fractions

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

Submission status: Runtime Error

Solution code:
import math

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

Submission status: Runtime Error

Solution code:
import functools import reduce
import fractions import gcd

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

print(reduce(gcd, A))

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
list1 = list(map(int,input().split()))
list1.sort()
list2 = []
for i in range(m-1):
	list2.append(list1[i+1]-list1[i])
list2.sort(reverse = True)
cut = 0
for j in range(n-1):
	cut+= list2[j]
print(max(list1)-min(list1)-cut)

Submission status: Runtime Error

Solution code:
import sys

readline = sys.stdin.buffer.readline


def sss(A, N):
    A.sort()
    if A[0] == 0:
        A.remove(0)
    for i in range(1, len(A)):
        A[i] = A[i] % A[0]
    if A[0] == sum(A):
        print(sum(A))
    else:
        return sss(A, N)


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

    sss(A, N)


main()

Submission status: Runtime Error

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

Submission status: Runtime Error

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

while len(a)>=2:
  for i in range(1,len(a)):
    a[i]=a[i]%a[0]
  if 0 in a:
    a.remove(0)
  a.sort()
    

print(a[0])

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
from functools import reduce
from math import gcd
input()
Ai = list(map(int, input().strip()))
print(reduce(gcd, Ai))

Submission status: Runtime Error

Solution code:
n = int(input())
*a, = sorted(map(int, input().split()))

m = a[0]
while any(map(lambda x: x%m, a)):
    a = sorted([m] + list(map(lambda x: x-m, a[1:])))
    m = a[0]

print(m)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

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

Submission status: Runtime Error

Solution code:
# Hariom_Pandey
# 11.11.2019
from functools import reduce
import math as mt
import sys
n = int(sys.stdin.readline())
H = list(map(int,sys.stdin.readline().split()))
print(reduce(mt.gcd,H))

Submission status: Runtime Error

Solution code:
# Hariom_Pandey
# 11.11.2019
from functools import reduce
import math as mt
n = int(sys.stdin.readline())
H = list(map(int,sys.stdin.readline().split())) 
print(reduce(mt.gcd,H))

Submission status: Runtime Error

Solution code:
import math

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

for i in range(1,n):
    ans = math.gcd(ans,li[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())
A = list(map(int,input().split()))

print(gcd_list(A))