Buggy python submission (verdict: Runtime Error):
def gcd(m, n):
    while n:
        m, n = n, m % n
    return m


N = int(input())
A = list(map(int, input().split()))
# gcd_list = []
# hoge = gcd(A[0], A[1])
# for i in range(2, N):
#     gcd_list.append(gcd(hoge, A[i]))
# gcd_list.sort()
# print(gcd_list[len(gcd_list)-2])
A.sort()
max_A = max(A)
gcd_list = []
for i in range(int(N/2):
    tmp = A[i]
    A[i] = max_A
    hoge = gcd(A[0], A[1])
    for j in range(2, int(N/2):
        hoge = gcd(A[j], hoge)
    gcd_list.append(hoge)
    A[i] = tmp

print(max(gcd_list))
# 最大の値と変えてもいい


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


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

left = [0]
right = [0]

for i in range(N):
    left.append(gcd(left[-1], A[i]))
    right.append(gcd(right[-1], A[(N-1)-i]))  # こっちのAは後ろからみる, iがN-1になった時はA[0]


right.reverse()  # indexが小さいほうが多くの数字を考慮した最大公約数になっている


gcd_list = [gcd(left[i], right[i+1]) for i in range(N)]

print(max(gcd_list))

Buggy python submission (verdict: Time Limit Exceeded):
def gcd(m, n):
    while n:
        m, n = n, m % n
    return m


N = int(input())

A = list(map(int, input().split()))
max_A = max(A)
gcd_list = []
for i in range(N):
    tmp = A[i]
    A[i] = max_A
    hoge = gcd(A[0], A[1])
    for j in range(2, N):
        hoge = gcd(A[j], hoge)
    gcd_list.append(hoge)
    A[i] = tmp

print(max(gcd_list))
# 最大の値と変えてもいい


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


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

left = [0]
right = [0]

for i in range(N):
    left.append(gcd(left[-1], A[i]))
    right.append(gcd(right[-1], A[(N-1)-i]))  # こっちのAは後ろからみる, iがN-1になった時はA[0]


right.reverse()  # indexが小さいほうが多くの数字を考慮した最大公約数になっている


gcd_list = [gcd(left[i], right[i+1]) for i in range(N)]

print(max(gcd_list))

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(set(map(int, input().split())))


# ユークリッド互除法の関数の定義
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


max_A = max(A)
gcd_list = []
if N == 1:
    print(A[0])
else:
    element = gcd(A[0], A[1])
    if N == 2:
        print(element)
        exit()
    else:
        for i in range(N):
            tmp = A[i]
            A[i] = max_A
            for j in range(2, N):
                element = gcd(element, A[i])
            gcd_list.append(element)
            A[i] = tmp
print(max(gcd_list))
# 最大の値と変えてもいい


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


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

left = [0]
right = [0]

for i in range(N):
    left.append(gcd(left[-1], A[i]))
    right.append(gcd(right[-1], A[(N-1)-i]))  # こっちのAは後ろからみる, iがN-1になった時はA[0]


right.reverse()  # indexが小さいほうが多くの数字を考慮した最大公約数になっている


gcd_list = [gcd(left[i], right[i+1]) for i in range(N)]

print(max(gcd_list))

Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce

N = int(input())

A = list(map(int, input().split()))
max_A = max(A)
gcd_list = []
for i in range(N):
    tmp = A[i]
    A[i] = max_A
    gcd = reduce(math.gcd, A)
    gcd_list.append(gcd)
    A[i] = tmp

print(max(gcd_list))
# 最大の値と変えてもいい


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


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

left = [0]
right = [0]

for i in range(N):
    left.append(gcd(left[-1], A[i]))
    right.append(gcd(right[-1], A[(N-1)-i]))  # こっちのAは後ろからみる, iがN-1になった時はA[0]


right.reverse()  # indexが小さいほうが多くの数字を考慮した最大公約数になっている


gcd_list = [gcd(left[i], right[i+1]) for i in range(N)]

print(max(gcd_list))

Buggy python submission (verdict: Runtime Error):
import functools
import math

N = int(input())

A = list(map(int, input().split()))
max_A = max(A)
gcd_list = []
for i in range(N):
    tmp = A[i]
    A[i] = max_A
    gcd = functools.reduce(math.gcd, A)
    gcd_list.append(gcd)
    A[i] = tmp

print(max(gcd_list))
# 最大の値と変えてもいい


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


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

left = [0]
right = [0]

for i in range(N):
    left.append(gcd(left[-1], A[i]))
    right.append(gcd(right[-1], A[(N-1)-i]))  # こっちのAは後ろからみる, iがN-1になった時はA[0]


right.reverse()  # indexが小さいほうが多くの数字を考慮した最大公約数になっている


gcd_list = [gcd(left[i], right[i+1]) for i in range(N)]

print(max(gcd_list))