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: Wrong Answer

Solution code:
# coding: utf-8

def gcd_list(l):
    for i in range(len(l)-1):
        x = max(l[i],l[i+1])
        y = min(l[i],l[i+1])
        if x%y==0:
            return y
        else:
            while x%y!=0:
                z = x%y
                x = y
                y = z
            else:
                return z

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

x = gcd_list(a) if len(a) != 1 else a[0]

print(x)

Submission status: Wrong Answer

Solution code:
# coding: utf-8

def gcd_list(l):
    for i in range(len(l)-1):
        x = max(l[i],l[i+1])
        y = min(l[i],l[i+1])
        if x%y==0:
            return y
        else:
            while x%y!=0:
                z = x%y
                x = y
                y = z
            else:
                return z

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

x = gcd_list(a)

print(x)

Submission status: Wrong Answer

Solution code:
# coding: utf-8

def gcd(x,y):
    x = max(x,y)
    y = min(x,y)
    if x%y==0:
        return y
    else:
        while x%Y!=0:
            z = x%y
            x = y
            y = z
        else:
            return z


def gcd_list(l):
    for i in range(len(l)-1):
        x = max(l[i],l[i+1])
        y = min(l[i],l[i+1])
        if x%y==0:
            return y
        else:
            while x%y!=0:
                z = x%y
                x = y
                y = z
            else:
                return z

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

x = gcd_list(a)

print(x)

Submission status: Wrong Answer

Solution code:
# coding: utf-8

def gcd(x,y):
    x = max(x,y)
    y = min(x,y)
    if x%y==0:
        return y
    else:
        while x%Y!=0:
            z = x%y
            x = y
            y = z
        else:
            return z


def gcd_list(l):
    for i in range(len(l)-1):
        x = max(l[i],l[i+1])
        y = min(l[i],l[i+1])
        if x%y==0:
            return y
        else:
            while x%y!=0:
                z = x%y
                x = y
                y = z
            else:
                return z

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

x = gcd_list(a)

print(x)

Submission status: Wrong Answer

Solution code:
import random
N = int(input())
A = list(map(int,input().split()))
while len(A) != 1:
    a = random.randint(0,N-1)
    b = random.randint(0,N-1)
    A[b] = A[b] - A[a]
    if A[b] <= 0:
        A.remove(A[b])
        N = N - 1
print(A[0])

Submission status: Wrong Answer

Solution code:
_ = input()
A = list(map(int, input().strip().split(' ')))

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

now_gcd = A[0]
for a in A[1:]:
  now_gcd = gcd(now_gcd, a)
  if now_gcd:
    break
print(now_gcd)

Submission status: Wrong Answer

Solution code:
def gcd(a,b):
  a,b=max(a,b),min(a,b)
  if b==0:
    return a
  else:
    return gcd(b,a%b)
 
n=int(input())
arr=list(map(int,input().split()))
for i in range(n-1):
  tmp=gcd(arr[i],arr[i+1])
print(tmp)

Submission status: Wrong Answer

Solution code:
N=int(input())
A = list(map(int, input().split()))
A.sort()
sa = []
for i in range(N-1):
    diff = A[i+1]-A[i]
    if diff > 0:
        sa.append(diff)
sa.sort()

if len(sa)>=2:
    score = sa[1] - sa[0]
    if score <= 0:
        print(sa[0])
    else:
        dai = max(score, sa[0])
        sho = min(score, sa[0])
        while dai-sho > 0:
            dai -= sho
            sho = min(dai, sho)
            dai = max(dai, sho)
        print(dai-sho if dai-sho > 0 else sho)
elif len(sa) == 1:
    print(sa[0])
else:
    print(A[0])

Submission status: Wrong Answer

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

a.sort()
a.reverse()

if a[0] == a[-1]:
    print(a[0])
else:
    while True:
        for i in range(len(a) - 1):
            if a[i] != 0 and a[i + 1] != 0:
                a[i] = a[i] % a[i + 1]
        a.sort()
        a.reverse()
        if a[0] == 1 or a[0] == 2:
            break
        else:
            continue
        break
    print(a[0])

Submission status: Wrong Answer

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

a.sort()
a.reverse()

for j in range(4):
    for i in range(len(a) - 1):
        if a[i] != 0 and a[i + 1] != 0:
            a[i] = a[i] % a[i + 1]
    a.sort()
    a.reverse()


print(a[0])

Submission status: Wrong Answer

Solution code:
input()
monsters = list(map(int, input().split()))
val = 1
min_monster = min(monsters)
divisors = [1]
while min_monster  >= val:
    val += 1
    if min_monster % val:
        continue
    min_monster = min_monster // val
    if not any([m % val for m in monsters]):
        divisors.append(val)
res = 1
for d in divisors:
    res *= d
print(res)

Submission status: Wrong Answer

Solution code:
input()
monsters = list(map(int, input().split()))
val = min(monsters) + 1
min_monster = val
while val > 0:
    val -= 1
    if min_monster % val:
        continue
    if not any([m % val for m in monsters]):
        break

print(val)

Submission status: Wrong Answer

Solution code:
N = int(input())
As = list(map(int, input().split()))
smallest = min(As)
l = []
for i in range(N):
    if As[i]%smallest > smallest:
        l.append(As[i]%smallest)
if len(l) > 0:
    smallest1 = min(l)
else:
    smallest1 = smallest
print(min(smallest,smallest1))

Submission status: Wrong Answer

Solution code:
N = int(input())
As = list(map(int, input().split()))
smallest = min(As)
l = []
for i in range(N):
    if As[i]%smallest > smallest:
        l.append(As[i])
if len(l) > 0:
    smallest1 = min(l)
else:
    smallest1 = smallest
print(min(smallest,smallest1))

Submission status: Wrong Answer

Solution code:
input()

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

while len(A) != 1:
    A.sort()
    for i, a in enumerate(A):
        if i + 1 < len(A) and A[i + 1] >= a > 0:
            A[i + 1] %= a
        print(A)
    A = [a for a in A if a > 0]

print(min(A))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
m = min(a)
flag = 0
for item in a:
  c = item % m
  if c:
    if m % 2 or c % 2:
      flag = 1
      break
    else:
      flag = 2
if flag:
  print(flag)
else:
  print(m)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
m = min(a)
flag = 0
for item in a:
  c = item % m
  if c:
    if m % 2 or c % 2:
      flag = 1
    else:
      flag = 2
    break
if flag:
  print(flag)
else:
  print(m)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
m = min(a)
flag = 0
for item in a:
  if item % m:
    flag = 1
    break
if flag:
  print(1)
else:
  print(m)

Submission status: Wrong Answer

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

a.sort()
a = np.array(a)
min_index = a.argmin()

for i in range(5):
    damaged = a % a[min_index]
    nonzero_index = damaged.nonzero()
    nonzero = damaged[nonzero_index]
    if nonzero.size == 0:
        break
    target = nonzero.argmin()
    min_index = nonzero_index[0][target]
    a[min_index] = nonzero[target]
print(a[min_index])

Submission status: Wrong Answer

Solution code:
#9:54〜10:28
N=int(input())
A=sorted(map(int,input().split()))
while len(A) != 1:
	B_nonzeros=[A[0]]
	for n in range(len(A)):
		i = A[n]%A[0]
		if i != 0:
			B_nonzeros.append(i)
	B_nonzeros.sort()
	A=B_nonzeros
	print(A)
print(A[0])

Submission status: Wrong Answer

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

ans = min(A)
aset = set(A)
A = list(aset)
N = len(A)
for i in range(N):
    for j in range(i+1,N):
        aset.add(A[i] % A[j])
        
Alist = list(aset)
Alist.sort()
for i in range(1,len(Alist)):
    ans = min(ans,Alist[i]-Alist[i-1])

print(ans)

Submission status: Wrong Answer

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

minimum = min(A)

if all(i == A[0] for i in A):
            print(1)
            exit()
            
def monst(mini):
    temp = []
    
    for i in A:
        temp.append(i % mini if i % mini != 0 else 10000)
    temp_min = min(temp)
    if temp_min < mini:
        monst(temp_min)
    else:
        print(mini)
        return
        
monst(minimum)

Submission status: Wrong Answer

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

minimum = min(A)
def monst(mini):
    temp = []
    if all(i == A[0] for i in A):
            print(1)
            exit()
    for i in A:
        temp.append(i % mini if i % mini != 0 else 10000)
    temp_min = min(temp)
    if temp_min < mini:
        monst(temp_min)
    else:
        print(mini)
        return
        
monst(minimum)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

#print(N)
#print(A)

if A[1]/A[0]>=1 and A[1]%A[0]==0:
  print(A[0])
elif A[1]/A[0]>=1 and A[1]%A[0]!=0:
  print(2)
else:
  print(1)

Submission status: Wrong Answer

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

#print(N)
#print(A)

if A[1]%A[0]==0:
  print(A[0])
else:
  print(1)

Submission status: Wrong Answer

Solution code:
import heapq

N = int(input())
A = list(map(int,input().split(' ')))
A_min = heapq.nsmallest(2,A)
X = A_min[0]
Y = A_min[1]

while X > 0 and Y > 0:
  if X <= Y:
    Y -= X
  else:
    X -= Y
print(max(X,Y))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = sorted(list(map(int,input().split(' '))))
X= A[0]
Y = A[1]

while X > 0 and Y > 0:
  if X <= Y:
    Y -= X
  else:
    X -= Y
print(max(X,Y))

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**7)
n=int(input())
a=list(map(int,input().split()))
def euc(x,y):
  x,y=max(x,y),min(x,y)
  if x%y==0:
    return y
  else:
    return euc(x,x%y)
k=a[0]
for i in range(1,n):
  k=euc(a[i],k)
print(k)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

min_num = min(a)
counter = 0
counter_2 = 0
for i in range(N):
    if a[i]%2 == 1:
        counter+=1
    if a[i]%min_num != 0:
        counter_2 += 1

if counter_2 == 0:
    print(min_num)

if counter == 0 and counter_2 != 0:
    print(2)

if counter != 0 and counter_2 != 0:
    print(1)

Submission status: Wrong Answer

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

counter = 0
for i in range(N):
    if a[i]%2 == 1:
        counter+=1

if counter == 0:
    print(2)

if counter != 0:
    print(1)

Submission status: Wrong Answer

Solution code:
def solve(m_list):
    min_val = m_list[0]
    # time O(N log(A))
    for m in m_list:
        if m % 2 == 1:
            return 1
        else:
            min_val = min(min_val, gcd(min_val, m))
    return min_val


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


def main():
    n = int(input())
    m_list = list(map(int, input().split()))

    ans = solve(m_list)
    print(ans)


main()

Submission status: Wrong Answer

Solution code:
def solve(m_list):
    min_val = 10 ** 9
    # time O(N log(A))
    for m in m_list:
        if m % 2 == 1:
            return 1
        else:
            min_val = min(min_val, gcd(min_val, m))
    return min_val


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


def main():
    n = int(input())
    m_list = list(map(int, input().split()))

    ans = solve(m_list)
    print(ans)


main()

Submission status: Wrong Answer

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

while True:
    A.sort(reverse=True)
    a = A[0]
    b = A[1]
    c = a - (a//b) * b
    if c == 0:
        break
    A[0] = c

print(min(A))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
min_m = min(A)
for i in range(len(A)):
    for j in range(len(A)):
        res = A[j] - A[i]*(A[j]//A[i])
        for k in A:
            if res == 0:
                break
            res = k%res
            if 1 <= res < min_m:
                min_m = k%res
print(min_m)

Submission status: Wrong Answer

Solution code:
N=int(input())
A = list(map(int, input().split()))
A.sort()
def score(a, b):
    if max(a, b) > 0 and min(a, b) <= 0:
        return max(a, b)
    if a > b:
        a, b = b, a
    return score(b-a, a)
 
print(score(A[1],A[0]))

Submission status: Wrong Answer

Solution code:
N=int(input())
A = list(map(int, input().split()))
A.sort()
sa = 10**10
index = 10**10
for i in range(N-1):
    if sa > A[i+1] - A[i]:
        sa = A[i+1] - A[i]
        index = i

def score(a, b):
    if max(a, b) > 0 and min(a, b) <= 0:
        return max(a, b)
    if a > b:
        a, b = b, a
    return score(b-a, a)

print(score(A[index+1],A[index]))

Submission status: Wrong Answer

Solution code:
N=int(input())
A = list(map(int, input().split()))
A.sort()
def hiku(a, b):
    if max(a, b) > 0 and min(a, b) <= 0:
        return max(a, b)
    if a > b:
        a, b = b, a
    return hiku(b-a, a)

sa = hiku(A[1],A[0])
print(sa)

Submission status: Wrong Answer

Solution code:
N=int(input())
A = list(map(int, input().split()))
A.sort()
def hiku(a, b):
    if max(a, b) > 0 and min(a, b) <= 0:
        return max(a, b)
    if a > b:
        a, b = b, a
    return hiku(b-a, a)

if A[0]==A[1]:
    print(A[0])
else:
    sa = hiku(A[1],A[0])
    print(sa)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=[int(i) for i in input().split()]
A.sort()
if A[0]==A[N-1]:
    print(A[0])
    exit()
else:
    for i in range(N):
        if A[i]%2==1:
            print(1)
            exit()
print(2)

Submission status: Wrong Answer

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

aa = min(a)

answer = aa
for i in a:
    if i % aa != 0:
        if i % 2 == 0 and aa % 2 == 0:
            answer = 2
        else:
            print(1)
            exit()

print(answer)

Submission status: Wrong Answer

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

aa = min(a)

for i in a:
    if i % aa != 0:
        print(1)
        exit()

print(aa)

Submission status: Wrong Answer

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

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

for i in range(n-1):
  a.insert(0,gcd(a[1],a[0]))
  del a[1:3]

print(a[0])

Submission status: Wrong Answer

Solution code:
import fractions
import functools

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

b = [i%2 for i in a if i%2 !=0]

if len(b) != 0:
  print(1)
else:
  print(functools.reduce(fractions.gcd, a))

Submission status: Wrong Answer

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

ans = min(a)

for i in range(n):
  b = [j%a[i] for j in a if j%a[i] != 0]  
  if len(b) == 0:
    continue
  b.sort()
  min_tmp = min(b[0],a[i]-b[-1])
  if min_tmp < ans:
    ans = min_tmp
  if ans == 1:
    break
print(ans)

Submission status: Wrong Answer

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

ans = min(a)

for i in range(n):
  b = [a[i] - j%a[i] for j in a if j%a[i] != 0]
  if len(b) == 0:
    continue
  if min(b) < ans:
    ans = min(b)
  if ans == 1:
    break
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
A.sort()
even_count = 0
odd_count = 0

for i in range(N):
    if A[i] % 2 == 0:
        even_count += 1
    else:
        odd_count += 1

if odd_count == 0 and A != [A[0] for i in range(N)]:
    print(2)
elif A == [A[0] for i in range(N)]:
    print(A[0])
else:
    print(1)

Submission status: Wrong Answer

Solution code:
from fractions import gcd

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import sys
from fractions import gcd
input = sys.stdin.readline

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

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
A = list(set(A))
ans = 0
A.sort()

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

for i in range(A[0],0,-1):
    count = 0
    for j in range(1,len(A),1):
        if A[j]%i != 0:
            break
        count += 1
    if count == len(A)-1:
        print(i)
        exit()
        
print("1")

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
from bisect import bisect_right

def main():
	N = int(input())
	A = input().split(" ")
	A = [int(s) for s in A]
	
	A.sort()
	a = A[0]
	tmp = bisect_right(A, a)
	if tmp == len(A):
		print(a)
		sys.exit()
			
	b = A[tmp]
	
	while True:
		#print("{} {}".format(a, b))
		tmp_min = min(a, b)
		tmp_max = max(a, b)
		tmp = tmp_max % tmp_min
		if tmp == 0:
			print(tmp_min)
			sys.exit()
		else:
			if a < b:
				b = tmp
			else:
				a = tmp
	
if __name__ == "__main__":
	main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys

def main():
	N = int(input())
	A = input().split(" ")
	A = [int(s) for s in A]
	
	ans = 1000000
	while True:
		endflg = True
		for i in range(len(A)):
			for j in range(i, len(A)):
				dd = -1
				tmp = -1
				if  A[i] == A[j]:
					continue
				if A[i] < A[j]:
					dd = j
					tmp = A[j] % A[i]
				else:
					dd = i
					tmp = A[i] % A[j]
					
				if tmp > 0:
					endflg = False
					A[dd] = tmp
					
		if endflg == True:
			break
				
	for i in A:
		if i < ans:
			ans = i
	print(ans)
	
if __name__ == "__main__":
	main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

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
    c = a % b
    return gcd(b, c)

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

print(ans)

Submission status: Wrong Answer

Solution code:
import fractions
def monsters(li,n):
    t = temp
    for i in range(1,n-1):
        t = fractions.gcd(t,li[i+1])
    return t

n = int(input())
li_a = list(map(int,input().split()))
temp = li_a[0]
print(monsters(li_a,n))

Submission status: Wrong Answer

Solution code:
n=int(input())
l=sorted(list(map(int,input().split())))
l2=[]
l3=[]
for i in range(1,int(n**(1/2)+1)):
  if n%i==0:                   
    l2.append(i)
    if i!=n//i:
      l2.append(n//i)
for i in l2:
  b=True
  for j in l:
    if j%i==0:
      pass
    else:
      b=False
  if b:
    l3.append(i)
print(max(l3))

Submission status: Wrong Answer

Solution code:
from sys import stdin
import numpy as np

N = int(stdin.readline().rstrip().split()[0])
A = [int(x) for x in stdin.readline().rstrip().split()]
# N, X = [int(x) for x in stdin.readline().rstrip().split()]

def G(_a, _b):
  if _a>=_b:
    a, b = _a, _b
  else:
    a, b = _b, _a
  
  while True:
    c = a%b
    if c == 0:
      break
    a,b = b,c
  
  return b
ans=0
L=list(set(A))
L_array = np.array(L)
if sum(L%np.min(L)):
  ans = min(L)
while ans==0:
  if len(L)==1:
    ans = L[0]
    break
  if min(L)==1:
    ans = 1
    break
  g = G(L[-2], L[-1])
  L[-2] = g
  L.pop()

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
mini = a.pop(a.index(min(a)))
semi_mini = a.pop(a.index(min(a)))
while mini > 0 and semi_mini > 0:
    if semi_mini > mini:
        semi_mini -= mini
    else:
        mini -= semi_mini
print(max(mini, semi_mini))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
mini = a.pop(a.index(min(a)))
semi_mini = a.pop(a.index(min(a)))
print(mini, semi_mini)
while mini > 0 and semi_mini > 0:
    if semi_mini > mini:
        semi_mini -= mini
    else:
        mini -= semi_mini
print(max(mini, semi_mini))

Submission status: Wrong Answer

Solution code:
n = int(input())
l = [int(i) for i in input().split()]
l.sort()
ans = 0

for i in range(n):
 if l[i] == 0:
     continue
 else:
     div = l[i]
     for j in range(i+1,n):
         l[j] = l[j] % div
     l.sort()

for i in range(n):
    if l[i] != 0:
        ans = l[i]
    else:
        continue

print(ans)

Submission status: Wrong Answer

Solution code:
INFO=int(input())

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

def Euclidean(m,n):
    while n!=0:
        temp = n
        n = m%n
        m=temp
    return m
    
output=DATA[0]
for i in range(1,INFO):
    print(output)
    output = Euclidean(DATA[i], output)
print(output)

Submission status: Wrong Answer

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

for k in range(infa):
    mina = min(a)
    print("ループ")

    for i in range(len(a)):
       
        if a[i] == mina:
            a[i] = mina
        else:
            a[i] = a[i] % mina
    
    a = [j for j in a if not j == 0]

    if len(a) == a.count(mina):
        break

print(mina)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
flag = True
while len(A) > 1:
    A.sort()
    devided_num = int(A[0])
    devi_lis = [devided_num]
    As = A
    As.pop(0)
    A =[_%devided_num for _ in As if _%devided_num > 0]
    A += devi_lis
print(A)

Submission status: Wrong Answer

Solution code:
###C - Monsters Battle Royale
N = int(input())
A = list(map(int, input().split()))

while(len(set(A)) != 1):
    print(A)
    for i in range(N):
        if A[i] > min(A):
            time = A[i] // min(A)
            if time == 1:
                A[i] =A[i] -  time * min(A)
            else:
                A[i] =A[i] -  (time - 1) * min(A)
                
print(min(A))

Submission status: Wrong Answer

Solution code:
def gcd(x, y):
  l = [x, y]
  l.sort()
  a = l[0]
  b = l[1]
  r = b % a
  while True:
    if r == 0:
      pre_r = a
      break
    pre_r = r
    r = b % r
  return(pre_r)
  
N = int(input())

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
import numpy as np
N = int(input())
M = [int(i) for i in input().split()]
# print(N)
# print(M)
M.sort()
if len(list(set(M))) == 1:
    print(M[0])
    exit()
else:
    min_M = min(M)
    a = [0]*(len(M)-1)
    for m in range(len(M)-1):
        a[m] = M[m+1] - M[m]
    min_delta = min(a)
    if min_M <= min_delta:
        print(min_M)
    else:
        while M[0] != M[1]:
            M = [M[0]] + a
            M.sort()
            min_M = min(M)
            a = [0]*(len(M)-1)
            for m in range(len(M)-1):
                # print(m)
                if M[m+1] != M[m]:
                    a[m] = M[m+1] - M[m]
                else:
                    a[m] = M[m]
        print(M[0])
        exit()

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
import numpy as np
N = int(input())
M = [int(i) for i in input().split()]
# print(N)
# print(M)
M.sort()
if len(list(set(M))) == 1:
    print(M[0])
    exit()
else:
    min_M = min(M)
    a = [0]*(len(M)-1)
    for m in range(len(M)-1):
        # print(m)
        a[m] = M[m+1] - M[m]
    min_delta = min(a)
    # print(min_delta)
    if min_M < min_delta:
        print(min_M)
    else:
        while M[0] != M[1]:
            # print("M")
            # print(M)
            M = [M[0]] + a
            M.sort()
            min_M = min(M)
            a = [0]*(len(M)-1)
            for m in range(len(M)-1):
                # print(m)
                if M[m+1] != M[m]:
                    a[m] = M[m+1] - M[m]
                else:
                    a[m] = M[m]
        print(M[0])
        exit()
# print(M)
# print(a)
# print(min(a))

Submission status: Wrong Answer

Solution code:
import sys

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

prev_a = [0]

while True:
  prev_a = a
  for item in a:
    if item >= 2:
      a = [i % item if i % item != 0 else i for i in a]
  
  if prev_a == a:
    for item in a:
      if item >= 2:
        print(item)
        sys.exit()

  if 1 in a:
    print(1)
    sys.exit()

Submission status: Wrong Answer

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


def bubble_sort(lst):
    for i in reversed(range(len(lst))):
        for j in range(i):
            if lst[j] > lst[j + 1]:
                lst[j], lst[j + 1] = lst[j + 1], lst[j]


def attack_monster(monster1, monster2):
    if monster1 > monster2:
        result = monster1 % monster2
    else:
        result = monster2 % monster1

    return result if result != 0 else min(monster1, monster2)


bubble_sort(a)
min_monster = a[0]
for i in range(1, n):
    if a[i] == 0:
        continue

    result = attack_monster(min_monster, a[i])
    min_monster = attack_monster(result, min_monster)


print(min_monster)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = sorted([int(i) for i in input().split()])
while True:
  hp = a[0]
  a = sorted(list(set(map(lambda x:x%hp, a))))
  a.remove(0)
  if a==[]:
    break
print(hp)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
print(min(a) if sum(list(map(lambda x:x%min(a), a)))==0 else 1)

Submission status: Wrong Answer

Solution code:
input()
m = sorted([int(i) for i in input().split()])
for i in m[1:]:
    if (i%m[0])!=0:
        print(1)
        exit()
print(m[0])

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
print(min(a) if list(map(lambda x:x%min(a), a))==[0]*n else 1)

Submission status: Wrong Answer

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

ANSWER=min(A)
A.remove(ANSWER)

for i in range(0,N-1):
  MIN=min(A)
  A.remove(MIN)
  
  if MIN%ANSWER!=0:
    ANSWER=MIN%ANSWER
  
  #print(ANSWER)
    
print (ANSWER)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
maxa = max(a)
mina = min(a)
if maxa == mina:
    print(a[0])
elif max(list(map(lambda x:x%mina,a))) < 1:
    print(mina)
elif max(list(map(lambda x:x%2,a))) == 1:
    print(1)
else:
    print(2)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
if max(a) == min(a):
    print(a[0])
elif max(list(map(lambda x:x%min(a),a))) < 1:
    print(min(a))
elif max(list(map(lambda x:x%2,a))) == 1:
    print(1)
else:
    print(2)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
if max(a) == min(a):
    print(a[0])
elif max(list(map(lambda x:x%2,a))) == 1:
    print(1)
else:
    print(2)

Submission status: Wrong Answer

Solution code:
N=int(input())
List=list(map(int,input().split()))
for i in range(10000):
  a=max(List)%min(List)
  if a>0:
    List.append(a)
  List.remove(max(List))
  if len(List)==1:
    break
print(List)

Submission status: Wrong Answer

Solution code:
N=int(input())
List=list(map(int,input().split()))
for i in range(max(List)):
  a=max(List)%min(List)
  if a>0:
    List.append(a)
  List.remove(max(List))
  if len(List)==1:
    break
print(List)

Submission status: Wrong Answer

Solution code:
N = int(input())

Als = []
i = input().split(" ")

for a in i:
  Als.append(int(a))

while(Als[1]>=1):
  for i in Als:
    if i < 0:
      Als.remove(i)
  Als.sort()
  for i in range(1,len(Als)):
    Als[i] = Als[i] - Als[0]

 


print(Als[0])

Submission status: Wrong Answer

Solution code:
N = int(input())

Als = []
i = input().split(" ")

for a in i:
  Als.append(int(a))

while(Als[1]>=1):
  Als.sort()
  for i in range(1,len(Als)):
    Als[i] = Als[i] - Als[0]

  for i in Als:
    if i < 0:
      Als.remove(i)


print(Als[0])

Submission status: Wrong Answer

Solution code:
N = int(input())

Als = []
i = input().split(" ")

for a in i:
  Als.append(int(a))

while(Als[1]>=1):
  Als.sort()
  for i in range(1,len(Als)):
    Als[i] -= Als[0]


print(Als[0])

Submission status: Wrong Answer

Solution code:
N = int(input())

Als = []
i = input().split(" ")

for a in i:
  Als.append(int(a))

while(Als[1]>=1):
  Als.sort()
  for i in range(1,len(Als)):
    Als[i] -= Als[0]


print(Als[0])

Submission status: Wrong Answer

Solution code:
N  = int(input())

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

i = 0
def euq(x,y):
  a = max(x,y)
  b = min(x,y)
  if a % b == 0:
    return b
  else:
  	return euq(b, a % b)
  
print(data)

while i < N-1:
  com =  euq(data[i],data[i + 1])
  data[i+1] = com
  i += 1
  
  

print(com)

Submission status: Wrong Answer

Solution code:
N = int(input())
h = sorted(list(map(int, input().split())))
a = h[0]
b = h[1]
while a!=0 and b!=0:
  if a > b:
    a = a-b
  else:
    b = b-a
if a==0:
  print(b)
else:
  print(a)

Submission status: Wrong Answer

Solution code:
N = int(input())
h = sorted(list(map(int, input().split())))
a = h[0]
b = h[1]
while a!=0 and b!=0:
  if a > b:
    a = a-b
  else:
    b = b-a
if a==0:
  print(b)
else:
  print(a)

Submission status: Wrong Answer

Solution code:
from queue import PriorityQueue
N = int(input())
A = map(int, input().split())
q = PriorityQueue()
for a in A:
  q.put(a)
x = q.get()
while not q.empty():
  y=q.get()
  if y == 0:
    break
  q.put(x % y)
  x = y
print(x)