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
import sys

# import bisect
# import math
# import itertools

import numpy as np


"""Template"""


class IP:
    """
    入力を取得するクラス
    """

    def __init__(self):
        self.input = sys.stdin.readline

    def I(self):
        """
        1文字の取得に使います
        :return: int
        """
        return int(self.input())

    def S(self):
        """
        1文字の取得(str
        :return: str
        """
        return self.input()

    def IL(self):
        """
        1行を空白で区切りリストにします(int
        :return: リスト
        """
        return list(map(int, self.input().split()))

    def SL(self):
        """
        1行の文字列を空白区切りでリストにします
        :return: リスト
        """
        return list(map(str, self.input().split()))

    def ILS(self, n):
        """
        1列丸々取得します(int
        :param n: 行数
        :return: リスト
        """
        return [int(self.input()) for _ in range(n)]

    def SLS(self, n):
        """
        1列丸々取得します（str
        :param n: 行数
        :return: リスト
        """
        return [self.input() for _ in range(n)]

    def SILS(self, n):
        """
        Some Int LineS
        横に複数、縦にも複数
        :param n: 行数
        :return: list
        """
        return [self.IL() for _ in range(n)]

    def SSLS(self, n):
        """
        Some String LineS
        :param n: 行数
        :return: list
        """
        return [self.SL() for _ in range(n)]


class Idea:
    def __init__(self):
        pass

    def HF(self, p):
        """
        Half enumeration
        半分全列挙です
        pの要素の和の組み合わせを作ります。
        ソート、重複削除行います
        :param p: list : 元となるリスト
        :return: list : 組み合わせられた和のリスト
        """
        return sorted(set(p[i] + p[j] for i in range(len(p)) for j in range(i, len(p))))

    def Bfs2(self, a):
        """
        bit_full_search2
        bit全探索の改良版
        全探索させたら2進数のリストと10進数のリストを返す
        :return: list２つ : １個目 2進数(16桁)  2個目 10進数
        """
        # 参考
        # https://blog.rossywhite.com/2018/08/06/bit-search/
        # https://atcoder.jp/contests/abc105/submissions/4088632
        value = []
        for i in range(1 << len(a)):
            output = []

            for j in range(len(a)):
                if self.bit_o(i, j):
                    """右からj+1番目のiが1かどうか判定"""
                    # output.append(a[j])
                    output.append(a[j])
            value.append([format(i, 'b').zfill(16), sum(output)])

        value.sort(key=lambda x: x[1])
        bin = [value[k][0] for k in range(len(value))]
        val = [value[k][1] for k in range(len(value))]
        return bin, val

    def S(self, s, r=0, m=-1):
        """
        ソート関係行います。色々な設定あります。
        :param s: 元となるリスト
        :param r: reversするかどうか 0=False 1=True
        :param m: （2次元配列）何番目のインデックスのソートなのか
        :return: None
        """
        r = bool(r)
        if m == -1:
            s.sort(reverse=r)
        else:
            s.sort(reverse=r, key=lambda x: x[m])

    def bit_n(self, a, b):
        """
        bit探索で使います。0以上のときにTrue出します
        自然数だからn
        :param a: int
        :param b: int
        :return: bool
        """
        return bool((a >> b & 1) > 0)

    def bit_o(self, a, b):
        """
        bit探索で使います。1のときにTrue出すよ
        oneで1
        :param a: int
        :param b: int
        :return: bool
        """
        return bool(((a >> b) & 1) == 1)

    def ceil(self, x, y):
        """
        Round up
        小数点切り上げ割り算
        :param x: int
        :param y: int
        :return: int
        """
        return -(-x // y)

    def ave(self, a):
        """
        平均を求めます
        :param a: list
        :return: int
        """
        return sum(a) / len(a)

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


"""ここからメインコード"""


def main():
    # 1文字に省略
    r, e = range, enumerate
    ip = IP()
    id = Idea()

    """この下から書いてね"""
    n = ip.I()
    a = ip.IL()
    a = np.array(a)
    i = 2
    k = a
    while k.dtype == "int32":
        k = a / [i] * n
        i += 1

    print(i - 1)
    

main()

Submission status: Wrong Answer

Solution code:
n=int(input())
data=[int(i) for i in input().split()]
data.sort()
while(True):
    best=min([num for num in data if num>0])
    best_i=-1
    best_j=-1
    for i in range(len(data)-1):
        j=i+1
        temp_data=data[:]
        temp_data[j]=temp_data[j]-temp_data[i]
        score=min([num for num in temp_data if num>0])
        if best>score:
            best_i=i
            best_j=j
            best=score
    if best_i!=-1:
        data[best_j]=data[best_j]-data[best_i]
        data.sort()
    else:
        break
print(min([num for num in data if num>0]))

Submission status: Wrong Answer

Solution code:
n=int(input())
data=[int(i) for i in input().split()]
data.sort()
while(True):
    best=min([num for num in data if num>0])
    best_i=-1
    best_j=-1
    for i in range(len(data)-1):
        for j in range(i+1,len(data)):
            temp_data=data[:]
            temp_data[j]=temp_data[j]-temp_data[i]
            score=min([num for num in temp_data if num>0])
            if best>score:
                best_i=i
                best_j=j
                best=score
    if best_i!=-1:
        data[best_j]=data[best_j]-data[best_i]
        data.sort()
    else:
        break
print(min([num for num in data if num>0]))

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
monster = np.array(list(map(int, input().split())))
while len(monster) > 1:
  min_ = np.min(monster)
  monster = monster % min_
  monster = np.where(monster > 0)
print(min_)

Submission status: Wrong Answer

Solution code:
N = int(input())
monster = list(map(int, input().split()))
monster.sort()
min1, min2 = monster[0], monster[1]
while min2 > 0:
  min1, min2 = min(min1, min2), max(min1,min2)%min(min1, min2)
print(max(min1, min2))

Submission status: Wrong Answer

Solution code:
from fractions import gcd
N = int(input())
monster = list(map(int, input().split()))
monster.sort()
min1, min2 = monster[0], monster[1]
print(gcd(min1, min2))

Submission status: Wrong Answer

Solution code:
def gcd(a, b):
  if a > b:
    min1, min2 = a, b
  else:
    min1, min2 = b, a
  if min2 == 0:
    return min1
  else:
    return gcd(min2, min1%min2)
N = int(input())
monster = list(map(int, input().split()))
monster.sort()
mina, minb = monster[0], monster[1]
print(gcd(mina, minb))

Submission status: Wrong Answer

Solution code:
N = int(input())
monstar = list(map(int, input().split()))
monstar.sort()
min1, min2 = monstar[0], monstar[1]
while min1 >= 1 and min2 >= 1:
  if min1 < min2:
    min2 -= min1
  else:
    min1 -= min2
print(max(min1, min2))

Submission status: Wrong Answer

Solution code:
N = int(input())
monster = list(map(int, input().split()))
def gcd(a, b):
  if b == 0:
    return a
  else:
    return gcd(a, a%b)
monster.sort()
min1, min2 = monster[0], monster[1]
print(gcd(min1, min2))

Submission status: Wrong Answer

Solution code:
_N = input()
A_list = list(map(int, input().split()))

print("{}".format(A_list))

while len(A_list) > 1:
    min_A = min(A_list)
    A_list = [min_A] + [A % min_A for A in A_list if A % min_A != 0]
    print("{}".format(A_list))

print("{}".format(A_list[0]))

Submission status: Wrong Answer

Solution code:
import random

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

def is_fighting(hps):
    suverve = 0
    for hp in hps:
        if hp > 0:
            suverve += 1

    if suverve == 1:
        return False
    return True

def can_atack(hp):
    if hp <= 0:
        return False
    return True

while is_fighting(hps):
    a = random.randrange(N)
    b = random.randrange(N)
    while a == b:
        b = random.randrange(N)

    if not can_atack(hps[a]) or not can_atack(hps[b]):
        continue
    hps[b] = hps[b] - hps[a] 
    
for hp in hps:
    if hp > 0:
        print(hp)
        exit()

Submission status: Wrong Answer

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

while len(set(A)) != 1:
    A.sort()
    print(A)
    B=list(map(lambda i:i%min(A), A[1:]))
    B.append(A[0])
    print(B)
    while B.count(0):
        B.remove(0)
    print(B)
    A=B
print(max(A))

Submission status: Wrong Answer

Solution code:
import collections
N = int(input())
mli = sorted(list(map(int,input().split())), reverse = False)
hp_min = mli[0]
index = 1
for i in range(1,N):
  if mli[index] % hp_min == 0:
    mli.pop(index)
  else:
    mli[index] = mli[index]%hp_min
    index += 1
    mli = sorted(mli, reverse = False)
    hp_min = mli[0]  
#if mli[i] % hp_min != 0:
  #hp_min = mli[i] % hp_min 
#print(mli)
print(hp_min)

Submission status: Wrong Answer

Solution code:
import collections
N = int(input())
mli = sorted(list(map(int,input().split())), reverse = False)
hp_min = mli[0]
index = 1
for i in range(1,N):
  if mli[index] % hp_min == 0:
    mli.pop(index)
  else:
    mli[index] = mli[index] % hp_min
    hp_min = mli[index]
    index += 1
    
#if mli[i] % hp_min != 0:
  #hp_min = mli[i] % hp_min 
print(mli)
print(hp_min)

Submission status: Wrong Answer

Solution code:
N = int(input())
An = [int(n) for n in input().split()]
M = sorted(set(An))
mini=M[0]
            
while len(M) > 1:
    M = [mini] + [x%mini for x in M[1:] if x % mini != 0]
    M.sort()
    if 1 in M:
        mini=1
        break
print(M[0])

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
a = int(input())
b = list(map(int,input().split()))
c = min(b)
def attack(b,c):
    fnc = lambda x:x%c
    b = list(map(fnc,b))
    b = [i for i in b if i != 0]
    if(len(b)==0):
        return c
    _c = min(b)
    if(c > _c):
        c = _c
        return attack(b,c)
    else:
        return c
print(attack(b,c))

Submission status: Wrong Answer

Solution code:
def gcd(a,b):
    r = a%b
    #print(a,b,r)
    if(r==0): return b
    return gcd(b,r)
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):
    gcd(hps[i], hps[0])
#print(hps)
for i in range(len(hps)):
    if(hps[i]==0): continue
    print(hps[i])
    break

Submission status: Wrong Answer

Solution code:
import itertools
n = int(input())
l = list(set(map(int,input().split())))
if min(l) == 1 or  len(set(l)) == 1:
    print(min(l))
else:
    l_set = sorted(list(set(l) | set([l[i] % l[j] for i,j in itertools.product(range(len(l)),range(len(l)))])))
    print(min([l_set[i+1] - l_set[i] for i in range(len(l_set)-1)]))

Submission status: Wrong Answer

Solution code:
import math

Submission status: Wrong Answer

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

print(m)

Submission status: Wrong Answer

Solution code:
import collections
N = int(input())
mli = sorted(list(map(int,input().split())), reverse = False)
hp_min = mli[0]
index = 1
for i in range(1,N):
  if mli[index] % hp_min == 0:
    mli.pop(index)
  else:
    mli[index] = mli[index] % hp_min
    hp_min = mli[index]
    index += 1
    
#if mli[i] % hp_min != 0:
  #hp_min = mli[i] % hp_min 
print(hp_min)

Submission status: Wrong Answer

Solution code:
input()
A = list(map(int, input().split(" ")))
A.sort()
def gcd(a, b):
    while b:
        a, b = b, a%b
    return a
rtn = 0
for i in range(0,len(A)-1):
    print(A[i], A[i+1], gcd(A[i], A[i+1]))
    A[i+1] = gcd(A[i], A[i+1])
print(A[-1])

Submission status: Wrong Answer

Solution code:
import fractions
from functools import reduce

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

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

Submission status: Wrong Answer

Solution code:
N = int(input())
v1, v2 = sorted(map(int, input().split()))[:2]
while v2 > 0:
    v1, v2 = v2, v1 % v2
print(v1)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
if min(a) == max(a):
    print(a[0])
else:
    mi = min(a)
    y = 0
    for i in range(1,mi+1):
        for na in a:
            if na%i != 0:
                break
    else:
        y = i
    print(y)

Submission status: Wrong Answer

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

hp = list(map(int, input().split()))
result = 0
checkyakusuru = []
checkodd = []
checkeven = []

if (hp.count(hp[0]) == m[0]):
    result = hp[0]

minhp = min(hp)

for p in hp:
    if (p % minhp == 0):
        checkyakusuru.append(1)
        break
    
    if (checkyakusuru.count(1) == m[0]):
        result = p
        break
    else:
        if (p % 2 == 0):
            checkeven.append(1)
        if (checkeven.count(1) == m[0]):
            result = 2
            break
        else:
            result = 1
            break
print(result)

Submission status: Wrong Answer

Solution code:
import collections
import itertools
import random

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

for j in a:
  if len(a)>=2:
    random.shuffle(a)
    for i in range(len(a)-1):
      a[i]=a[i+1]
      if a[i]==0:
        del a[i]
      else:
        continue
  else:
    print(a)

Submission status: Wrong Answer

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


kari3 = 0
for j in range(A[N-1]):
    #0以外の最小値取得
    for i in range(N-1):
        if A[i] >= 1:
            kari = (A[i+1]//A[i])*A[i]
            #print(A[i+1])
            if A[i+1] == 1 and i <= N-3:
                print(i)
                kari = A[i+2]
            if A[i+1] == 1 and i > N-3:
                kari3 = 1 
            kari2 = i
            break
    for i in range(N-1):
        if A[i+1] > 1 and i >= kari2:
            A[i+1] = A[i+1]-kari
        A.sort()

    if A[N-2] == 0:
        break
    if kari3 == 1 :
        break


ans = max(A)    


print(ans)

Submission status: Wrong Answer

Solution code:
N= input()
list_monster = []
sec_list=[]
list_monster = list(map(int, input().split()))
num = 0
count = int(N)-2
min_monster= int(min(list_monster))
index = list_monster.index(min(list_monster))


while True:
    for n in range(int(N)):
        if n!=index and list_monster[n]>=1:
            list_monster[n] = list_monster[n] - list_monster[index]
            
        elif list_monster[n]<1:
            num = num+1
    min_monster = int(min(list_monster))
    index = list_monster.index(min(list_monster))
    if num==count:
        break
   # print(sec_list)

#print(list_monster)

for i in range(int(N)):
    if list_monster[i]>=1:
        sec_list.append(list_monster[i])

#print(sec_list)
print(min(sec_list))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
input()
A = list(map(int, input().split(" ")))
A.sort()
max = A[len(A)-1]
b1 = 0 # あまりが1以上で最小になった奴
b2 = max # その時のあまり
for a1 in A[0:len(A)-1]:
    tmp = max%a1
    if tmp != 0 and tmp < b2:
        b1 = a1
        b2 = tmp
print(A[0] if b1 == 0 else b1-b2)

Submission status: Wrong Answer

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

res = min(A)

cand = A[0]

for i in range(1,N):
    tmp = [cand, A[i] - A[i-1], A[i] % cand]
    cand = min([e for e in tmp if e > 0])

    if cand == 1:
        break

print(cand)

Submission status: Wrong Answer

Solution code:
def main():
  N = int(input())
  monsters = list(map(int, input().split()))

  monsters = sorted(monsters)
  # print(monsters)
  prev = None
  while True:
    # print('==============================')
    monsters = sorted(monsters)
    prev = monsters
    # print(monsters)
    
    for i in range(1, len(monsters)):
      monsters[i] = monsters[i] % monsters[0]

    # print(monsters)
    if 0 in monsters:
      monsters = list(set(monsters))
      monsters.remove(0)
      monsters = sorted(monsters)

    # print(monsters)
    if len(monsters) == 2:
      if monsters[1] < monsters[0]:
        monsters[0] -= monsters[1]
        continue
      # print('a')
      last = monsters[1] - monsters[0]
      if last == 0:
        break
      monsters[0] = last
      monsters.remove(monsters[1])
      # print(monsters)

    if len(monsters) == 1:
      break

    if prev == monsters:
      monsters[0] -= monsters[1]



  print(monsters[0])

main()

Submission status: Wrong Answer

Solution code:
n = int(input())
l = list(map(int, input().split()))
l.sort()
def a(i, j):
  return l[i] % l[j]
def b(i, j):
  return min(a(i, j), l[j]-a(i, j))
for i in range(1, n):
    for j in range(i):
      c = float('inf')
      if b(i, j) < c and b(i, j) != 0:
        c = b(i, j)
      else:
        c = min(l)
print(c)

Submission status: Wrong Answer

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

A = list(set(A))
if 1 == len(A):
    print(A[0])
elif 2 == len(A):
    print(min(A))
else:
    print(1 if any(a % 2 == 1 for a in A) else 2)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = sorted(map(int,input().split()))
b = [a[i] - a[i-1] for i in range(1,n) if a[i] - a[i-1] != 0]

amin = min(a)
c = [i % amin for i in a if i % amin != 0]
if c:
    c = min(c)
    amin = min(amin,c)


if b:
    b = min(b)
    d = [i % b for i in a if i % b != 0]
    if d:
        d = min(d)
        b = min(b,d)
    amin = min(amin,b)



print(amin)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat Feb 16 20:59:16 2019
 
@author: doppe
"""
N = int(input())
 
A = [int(i) for i in input().split()]
 
minValue = min(A)
 
ans = 1
ansList = [1]
i = 2
while i * i <= minValue:
    j = 1
    for k in A:
        if (k % i != 0):
            break
        if (j == len(A)):
            ans = i
            ansList.append(i)
        j += 1
    i += 1
flg = 0
 
for i in range(0, len(ansList)):
    value = minValue / ansList[i]
 
    j = 1
    for k in A:
        if (k % value != 0):
            break
        if (j == len(A)):
            ans = value
            flg = 1
        j += 1
    if (flg == 1):
        break
            
print(int(ans))

Submission status: Wrong Answer

Solution code:
n = int(input())
listA=list(map(int, input().split()))
listA.sort()
min1=listA[0]
min2=listA[1]
flag=1
while flag:
    flag=0
    if min2 > min1 and min2-min1 > 0:
        min2-=min1
        flag=1
    if min1 > min2 and min1-min2 > 0:
        min1-=min2
        flag=1
minmin1=min(min1, min2)
if len(listA)>2:
    min2 = listA[1]
    min3=listA[2]
    flag = 1
    while flag:
        flag = 0
        if min3 > min2 and min3-min2 > 0:
            min3 -= min2
            flag = 1
        if min2 > min3 and min2-min3 > 0:
            min2 -= min3
            flag = 1
    minmin2=min(min2, min3)
    min2 = listA[0]
    min3 = listA[2]
    flag = 1
    while flag:
        flag = 0
        if min3 > min2 and min3-min2 > 0:
            min3 -= min2
            flag = 1
        if min2 > min3 and min2-min3 > 0:
            min2 -= min3
            flag = 1
    minmin3 = min(min2, min3)
    print(min(minmin1, minmin2, minmin3))
else:
    print(minmin1)

Submission status: Wrong Answer

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

hp = list(map(int, input().split()))
result = 0
checkyakusuru = []
checkodd = []
checkeven = []

if (hp.count(hp[0]) == m[0]):
    result = hp[0]

minhp = min(hp)

for p in hp:
    if (p % minhp == 0):
        checkyakusuru.append(1)
    
    if (checkyakusuru.count(1) == m[0]):
        result = p
        break
    else:
        if (p % 2 == 0):
            checkeven.append(1)
        if (checkeven.count(1) == m[0]):
            result = 2
            break
        else:
            result = 1
            break
print(result)

Submission status: Wrong Answer

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

res = float('inf')
A_sum = sum(A)

for i in A:
    res = min(res,A_sum%i if A_sum%i else i)

print(res)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(x) for x in input().split()]
min_A = min(A)
s = min_A
for i in range(N):
  for j in range(i):
    d = abs(A[i]-A[j])
    if d > 0 and d < s:
      s = d
print(s)

Submission status: Wrong Answer

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

if 1 == len(list(set(A))):
    print(A[0])
elif 2 == len(A):
    print(min(A))
else:
    print(1 if any(a % 2 == 1 for a in A) else 2)

Submission status: Wrong Answer

Solution code:
N = int(input())
monsterlist = list(map(int,input().split()))
monsterlist.sort()
minnum = monsterlist[0]
if minnum % 2 == 0:
    count = 0
    for i in range(1,N):
        if monsterlist[i] % minnum != 0:
            count += 1
            break
    if count == 0:
        print(minnum)
    else:
        count = 0
        for i in range(1,N):
            if monsterlist[i] % 2 != 0:
                count += 1
                print("1")
                break
        if count == 0:
            print("2")

else:
    count = 0
    for i in range(1,N):
        if monsterlist[i] % minnum != 0:
            count += 1
            break
    if count == 0:
        print(minnum)
    else:
        count = 0
        for i in range(1,N):
            if monsterlist[i] % 2 == 0:
                if monsterlist[i] % minnum != 0:
                    count += 1
                    print("1")
                    break
        if count == 0:
            print("2")

Submission status: Wrong Answer

Solution code:
n = int(input())
listA=list(map(int, input().split()))
listA.sort()
min1=listA[0]
min2=listA[1]
flag=1
while flag:
    flag=0
    if min2 > min1 and min2-min1 > 0:
        min2-=min1
        flag=1
    if min1 > min2 and min1-min2 > 0:
        min1-=min2
        flag=1
minmin1=min(min1, min2)
if len(listA)>2:
    min2 = listA[1]
    min3=listA[2]
    flag = 1
    while flag:
        flag = 0
        if min3 > min2 and min3-min2 > 0:
            min3 -= min2
            flag = 1
        if min2 > min3 and min2-min3 > 0:
            min2 -= min3
            flag = 1
    minmin2=min(min2, min3)
    print(min(minmin1, minmin2))
else:
    print(minmin1)

Submission status: Wrong Answer

Solution code:
N=int(input())
As=[int(x) for x in input().split()]
As.sort()
As.reverse()
print(As)
LL=[]

def ret_factor(num):
    while num % 2 == 0:
        num /= 2
        yield 2

    i = 3
    while num != 1:
        if num % i == 0:
            num /= i
            yield i
        else:
            i += 2


def intersect_list(lst1, lst2):
    arr = []
    lst = lst1.copy()
    for element in lst2:
        try:
            lst.remove(element)
        except ValueError:
            pass
        else:
            arr.append(element)
    return arr

cr=As[0] 
for A in As:
    LL.append(list(ret_factor(A)))

rL=[]
for L in LL:
    for L2 in LL:
        r=1
        for k in intersect_list(L,L2):
           r*=k
        rL.append(r)

print(min(rL))

Submission status: Wrong Answer

Solution code:
N = int(input())
monster = list(map(int, input().split()))
monster.sort()
if len(monster) == 1:
  print(monster[0])
else:
  min1, min2 = monster[0], monster[1]
  while min1 > 0 and min2 > 0:
    if min1 < min2:
      min2 -= min1
    else:
      min1 -= min2
  print(max(min1, min2))

Submission status: Wrong Answer

Solution code:
N = int(input())
monster = input().split()
monster = [int(life) for life in monster]
countEven = 0
for i in monster:
    if i % 2 == 0:
        countEven += 1

monster.sort()
if monster.count(monster[0]) == N:
    print(monster[0])
elif countEven == N:
    print(2)
else:
    print(1)

Submission status: Wrong Answer

Solution code:
def read():
    return int(input())

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

n = read()
a = reads()
c = [0]*n
cnt = 0
m = min(a)

for i in range(n):
    c[i] = a[i] % m
    if not  a[i] % 2 == 0:
        cnt = 1
if sum(c) == 0:
    print(m)
    exit()
if cnt == 1:
    print(1)
else:
    print(2)

Submission status: Wrong Answer

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

for i in A[1:]:
    x = i%ans
    if not x == 0:
        ans = min(ans, i%ans)

print(ans)

Submission status: Wrong Answer

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

dp = [[max(A) + 1 for _ in range(N)] for _ in range(max(A) + 1)]
for i in range(N):
    dp[0][i] = A[i]
for i in range(max(A)):
    for j in range(N):
        for k in range(N):
            if not j == k:
                if not dp[i][j] - dp[i][k] <= 0:
                    dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] - dp[i][k])
result = max(A)
for i in dp:
    result = min(result, min(i))
print(result)

Submission status: Wrong Answer

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

l = sorted(l)


pre = min(l)
ans = pre
if all([i % pre == 0 for i in l]):
    print(pre)
else:
    print(1)

Submission status: Wrong Answer

Solution code:
""" AtCoder"""

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

A_min = min(A)
count = 0
for i in range(N):
    if A[i] % A_min == 0:
        count += 1
    else:
        break

if count == N:
    print(A_min)
    exit()

for i in range(N):
    if A[i] % 2 == 1:
        print(1)
        exit()

if A_min >= 4:
    for i in range(4, A_min+1, 2):
        count = 0
        for j in range(N):
            if A[j] % i == 0:
                count += 1
            else:
                count = 0
                break
        if count == N:
            print(i)
            exit()

print(2)

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input()) 
#n=4
lst = [int(i) for i in input().split()]
#lst = [2, 2, 8, 40]
#lst = [5, 13, 8, 1000000000]
#lst = [0, 1, 0]
hps = np.array(lst)
while(1):
    hps = sorted(hps)
    #print(hps)
    if(hps[0]==0): break
    if(hps[0]==hps[len(hps)-1]): break
    hps[1] = hps[1] - hps[0]
for i in range(len(hps)):
    if(hps[i]==0): continue
    print(hps[i])
    break

Submission status: Wrong Answer

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

while(a[-1] != 1):
	for i in range(len(a)):
		if a[-i] == 0:
			continue
		else:
			m = a[-i]
			break
	b = []

	for i in range(len(a) - 1):
		b.append(a[i] % m)

	if  max(b) == 0:
		print(m)
		exit()
	else:
		b.append(m)
		a = sorted(b, reverse=True)
		print(b)
print('1')

Submission status: Wrong Answer

Solution code:
number=int(input())
hitpoint=list(map(int,input().split()))
xyz=[]
png=[]
for i in range(len(hitpoint)):
    xyz.append(hitpoint[i]%2)
if hitpoint.count(hitpoint[0])==len(hitpoint):
    print(hitpoint[0])
elif min(hitpoint)==1:
    print(1)
elif max(hitpoint)%min(hitpoint)==0 and hitpoint[1]%min(hitpoint)==0:
    for i in range(len(hitpoint)):
        png.append(hitpoint[i]%min(hitpoint))
    if png.count(0)==len(png):
        print(min(hitpoint))
    else:
        if hitpoint.count(1)!=0:
            print(1)
        elif xyz.count(0)!=len(xyz):
            print(1)
        elif xyz.count(1)==len(xyz):
            print(1)
        else:
            print(2)
elif hitpoint.count(1)!=0:
    print(1)
elif xyz.count(0)!=len(xyz):
    print(1)
elif xyz.count(1)==len(xyz):
    print(1)
else:
    print(2)

Submission status: Wrong Answer

Solution code:
N = int(input())
An = [int(n) for n in input().split()]
M = sorted(set(An))
mini=M[0]
            
while len(M) > 1:
    M = [mini] + [x-mini for x in M[1:] if x % mini != 0]
    M.sort()
    if 1 in M:
        mini=1
        break
print(M[0])

Submission status: Wrong Answer

Solution code:
N = int(input())
AList = input().split(" ")
AList = [int(i) for i in AList]
AList.sort()
minValue = AList[0]

for i in range(len(AList)) :
    if AList[i] % minValue > 0 : 
        minValue = AList[i] % minValue
        AList[i] = minValue
for i in range(len(AList)) :
    if AList[i] % minValue > 0 : 
        minValue = AList[i] % minValue
        AList[i] = minValue


print(minValue)

Submission status: Wrong Answer

Solution code:
import collections
N = int(input())
mli = sorted(list(map(int,input().split())), reverse = False)
hp_min = mli[0]
for i in range(1,N):
  #if mli[i] % hp_min == 0:
    #mli.pop(i)
    #N = N-1
    #print(N)
  if mli[i] % hp_min != 0:
    hp_min = mli[i] % hp_min
print(hp_min)

Submission status: Wrong Answer

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

a.sort()
min_val = a[0]

amaris = [a[i+1]%a[i] for i in range(n-1) if a[i+1]%a[i]!=0]
#print(amaris)
if min_val == 1:
    print(min_val)
else:
    for i in range(n):
        t = a[i]
        for t_a in amaris:
            val = t%t_a
            if val != 0 and val < min_val:
                min_val = val
            if min_val == 1:
                print(min_val)
                sys.exit()

    print(min_val)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = sorted(map(int,input().split()))
b = [a[i] - a[i-1] for i in range(1,n) if a[i] - a[i-1] != 0]


ans = min(a[0],min(b)) if b else a[0]
c = [i % ans for i in a if i % ans != 0]

if c:
    ans = min(c)

print(ans)

Submission status: Wrong Answer

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

A.sort()
if 1 == len(list(set(A))):
    print(A[0])
else:
    print(1 if any(a % 2 == 1 for a in A) else 2)