Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
li = list(map(int,input().split()))
ans = 0
lgcd = [li[0]]
rgcd = [li[-1]]

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

for i in range(n-1):
    lgcd.append(gcd(lgcd[-1],li[i+1]))
    rgcd.insert(0,gcd(rgcd[0],li[-(i+2)]))

gcd_list = [gcd(lgcd[i],rgcd[i+2]) for i in range(n-2)]

gcd_list.append(lgcd[-2])
gcd_list.append(rgcd[1])

print(max(gcd_list))


Fixed submission:
n = int(input())
li = list(map(int,input().split()))
ans = 0
lgcd = [0]*n
rgcd = [0]*n
lgcd[0] = li[0]
rgcd[-1] = li[-1]

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

for i in range(n-1):
    lgcd[i+1] = gcd(lgcd[i],li[i+1])
    rgcd[-i-2] = gcd(rgcd[-i-1],li[-(i+2)])

gcd_list = [gcd(lgcd[i],rgcd[i+2]) for i in range(n-2)]

gcd_list.append(lgcd[-2])
gcd_list.append(rgcd[1])

print(max(gcd_list))

Buggy python submission (verdict: Runtime Error):
import numpy as np

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

for i in range(n-1):
    lgcd.append(np.gcd(lgcd[-1],li[i+1]))
    rgcd.insert(0,np.gcd(rgcd[0],li[-(i+2)]))

gcd_list = [lgcd[-2],rgcd[1]]

for i in range(n-2):
    gcd_list.append(np.gcd(lgcd[i],rgcd[i+2]))

print(max(gcd_list))


Fixed submission:
n = int(input())
li = list(map(int,input().split()))
ans = 0
lgcd = [0]*n
rgcd = [0]*n
lgcd[0] = li[0]
rgcd[-1] = li[-1]

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

for i in range(n-1):
    lgcd[i+1] = gcd(lgcd[i],li[i+1])
    rgcd[-i-2] = gcd(rgcd[-i-1],li[-(i+2)])

gcd_list = [gcd(lgcd[i],rgcd[i+2]) for i in range(n-2)]

gcd_list.append(lgcd[-2])
gcd_list.append(rgcd[1])

print(max(gcd_list))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
li = list(map(int,input().split()))
ans = 0
lgcd = [li[0]]
rgcd = [li[-1]]

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

for i in range(n-1):
    lgcd.append(gcd(lgcd[-1],li[i+1]))
    rgcd.insert(0,gcd(rgcd[0],li[-(i+2)]))

gcd_list = [lgcd[-2],rgcd[1]]

for i in range(n-2):
    gcd_list.append(gcd(lgcd[i],rgcd[i+2]))

print(max(gcd_list))


Fixed submission:
n = int(input())
li = list(map(int,input().split()))
ans = 0
lgcd = [0]*n
rgcd = [0]*n
lgcd[0] = li[0]
rgcd[-1] = li[-1]

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

for i in range(n-1):
    lgcd[i+1] = gcd(lgcd[i],li[i+1])
    rgcd[-i-2] = gcd(rgcd[-i-1],li[-(i+2)])

gcd_list = [gcd(lgcd[i],rgcd[i+2]) for i in range(n-2)]

gcd_list.append(lgcd[-2])
gcd_list.append(rgcd[1])

print(max(gcd_list))

Buggy python submission (verdict: Runtime Error):
n = int(input())
li = list(map(int,input().split()))
ans = 0

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

def gcd_list2(li):
    a = gcd(li[0],li[1])
    for i in range(n-1):
        a = gcd(a,li[i])
    return a

for i in range(n):
    li2 = li[:i] + li[i+1:]
    a = gcd_list2(li2)
    if a > ans:
        ans = a

print(ans)


Fixed submission:
n = int(input())
li = list(map(int,input().split()))
ans = 0
lgcd = [0]*n
rgcd = [0]*n
lgcd[0] = li[0]
rgcd[-1] = li[-1]

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

for i in range(n-1):
    lgcd[i+1] = gcd(lgcd[i],li[i+1])
    rgcd[-i-2] = gcd(rgcd[-i-1],li[-(i+2)])

gcd_list = [gcd(lgcd[i],rgcd[i+2]) for i in range(n-2)]

gcd_list.append(lgcd[-2])
gcd_list.append(rgcd[1])

print(max(gcd_list))

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

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

def gcd_list2(li):
    a = math.gcd(li[0],li[1])
    for i in range(n-1):
        a = math.gcd(a,li[i])
    return a

for i in range(n):
    li2 = li[:i] + li[i+1:]
    a = gcd_list2(li2)
    if a > ans:
        ans = a

print(ans)


Fixed submission:
n = int(input())
li = list(map(int,input().split()))
ans = 0
lgcd = [0]*n
rgcd = [0]*n
lgcd[0] = li[0]
rgcd[-1] = li[-1]

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

for i in range(n-1):
    lgcd[i+1] = gcd(lgcd[i],li[i+1])
    rgcd[-i-2] = gcd(rgcd[-i-1],li[-(i+2)])

gcd_list = [gcd(lgcd[i],rgcd[i+2]) for i in range(n-2)]

gcd_list.append(lgcd[-2])
gcd_list.append(rgcd[1])

print(max(gcd_list))

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

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

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

def gcd_list2(li):
    a = math.gcd(li[0],li[1])
    for i in range(n-1):
        a = math.gcd(a,li[i])
    return a

for i in range(n):
    li2 = li[:i] + li[i+1:]
    a = gcd_list2(li2)
    if a > ans:
        ans = a

print(ans)


Fixed submission:
n = int(input())
li = list(map(int,input().split()))
ans = 0
lgcd = [0]*n
rgcd = [0]*n
lgcd[0] = li[0]
rgcd[-1] = li[-1]

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

for i in range(n-1):
    lgcd[i+1] = gcd(lgcd[i],li[i+1])
    rgcd[-i-2] = gcd(rgcd[-i-1],li[-(i+2)])

gcd_list = [gcd(lgcd[i],rgcd[i+2]) for i in range(n-2)]

gcd_list.append(lgcd[-2])
gcd_list.append(rgcd[1])

print(max(gcd_list))