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

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

gcd_l = [0] * N

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

gcd_r = [0] * N

gcd_r[N - 1] = A[N - 1]
for i in reversed(range(0, N - 1)):
    gcd_l[i] = math.gcd(gcd_r[i + 1], A[i])

gcd_lr = [0] * N

for i in range(N):
    if i == 0:
        gcd_lr[i] = gcd_r[i + 1]
    elif 1 <= i <= N - 2:
        gcd_lr[i] = math.gcd(gcd_l[i - 1], gcd_r[i + 1])
    elif i == N - 1:
        gcd_lr[i] = gcd_l[i - 1]

print(max(gcd_lr))


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


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

gcd_l = [0] * N

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

gcd_r = [0] * N

gcd_r[N - 1] = A[N - 1]
for i in reversed(range(0, N - 1)):
    gcd_r[i] = gcd(gcd_r[i + 1], A[i])

gcd_lr = [0] * N

for i in range(N):
    if i == 0:
        gcd_lr[i] = gcd_r[i + 1]
    elif 1 <= i <= N - 2:
        gcd_lr[i] = gcd(gcd_l[i - 1], gcd_r[i + 1])
    elif i == N - 1:
        gcd_lr[i] = gcd_l[i - 1]

print(max(gcd_lr))

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

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


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


max_gcd = 0

for i in range(N):
    popped = A.pop(i)
    tmp_max_gcd = gcd_list(A)
    if tmp_max_gcd > max_gcd:
        max_gcd = tmp_max_gcd
    A.insert(i, popped)

print(max_gcd)


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


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

gcd_l = [0] * N

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

gcd_r = [0] * N

gcd_r[N - 1] = A[N - 1]
for i in reversed(range(0, N - 1)):
    gcd_r[i] = gcd(gcd_r[i + 1], A[i])

gcd_lr = [0] * N

for i in range(N):
    if i == 0:
        gcd_lr[i] = gcd_r[i + 1]
    elif 1 <= i <= N - 2:
        gcd_lr[i] = gcd(gcd_l[i - 1], gcd_r[i + 1])
    elif i == N - 1:
        gcd_lr[i] = gcd_l[i - 1]

print(max(gcd_lr))

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

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


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


max_gcd = 0

for i in range(N):
    popped = A.pop(i)
    tmp_max_gcd = gcd_list(A)
    if tmp_max_gcd > max_gcd:
        max_gcd = tmp_max_gcd
    A.append(popped)

print(max_gcd)


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


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

gcd_l = [0] * N

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

gcd_r = [0] * N

gcd_r[N - 1] = A[N - 1]
for i in reversed(range(0, N - 1)):
    gcd_r[i] = gcd(gcd_r[i + 1], A[i])

gcd_lr = [0] * N

for i in range(N):
    if i == 0:
        gcd_lr[i] = gcd_r[i + 1]
    elif 1 <= i <= N - 2:
        gcd_lr[i] = gcd(gcd_l[i - 1], gcd_r[i + 1])
    elif i == N - 1:
        gcd_lr[i] = gcd_l[i - 1]

print(max(gcd_lr))