Buggy python submission (verdict: Time Limit Exceeded):
import functools
n = int(input())
a_list = list(map(int,input().split()))

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

res = []
tmp = []
for i in range(n):
    if a_list[i] in tmp:
        continue
    if a_list[:i]==[]:
        res.append(functools.reduce(gcd, a_list[i+1:]))
    elif a_list[i+1:]==[]:
        res.append(functools.reduce(gcd, a_list[:i]))
    else:
        l_gcd = functools.reduce(gcd, a_list[:i])
        r_gcd = functools.reduce(gcd, a_list[i+1:])
        res.append(gcd(l_gcd,r_gcd))
    tmp.append(a_list[i])
print(max(res))

Fixed submission:
n = int(input())
a_list = list(map(int,input().split()))

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

res = []
l_gcd = [0]*(n+2)
r_gcd = [0]*(n+2)
for i in range(n+1):
    if i ==0:
        l_gcd[i] = 0
        r_gcd[n-i+1] = 0
        continue
    l_gcd[i] = gcd(l_gcd[i-1], a_list[i-1])
    r_gcd[n-i] = gcd(r_gcd[n-i+1], a_list[n-i])

for i in range(n+1):
    res.append(gcd(l_gcd[i],r_gcd[i+1]))

print(max(res))

Buggy python submission (verdict: Time Limit Exceeded):
import functools
n = int(input())
a_list = list(map(int,input().split()))

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

res = []
tmp = []
for i in range(n):
    if a_list[:i]==[]:
        res.append(functools.reduce(gcd, a_list[i+1:]))
    elif a_list[i+1:]==[]:
        res.append(functools.reduce(gcd, a_list[:i]))
    else:
        l_gcd = functools.reduce(gcd, a_list[:i])
        r_gcd = functools.reduce(gcd, a_list[i+1:])
        res.append(gcd(l_gcd,r_gcd))
print(max(res))

Fixed submission:
n = int(input())
a_list = list(map(int,input().split()))

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

res = []
l_gcd = [0]*(n+2)
r_gcd = [0]*(n+2)
for i in range(n+1):
    if i ==0:
        l_gcd[i] = 0
        r_gcd[n-i+1] = 0
        continue
    l_gcd[i] = gcd(l_gcd[i-1], a_list[i-1])
    r_gcd[n-i] = gcd(r_gcd[n-i+1], a_list[n-i])

for i in range(n+1):
    res.append(gcd(l_gcd[i],r_gcd[i+1]))

print(max(res))

Buggy python submission (verdict: Time Limit Exceeded):
import functools
n = int(input())
a_list = list(map(int,input().split()))

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

res = []
tmp = []
for _ in range(n):
    e = a_list.pop(0)
    if e in tmp or e in res:
        continue
    res.append(functools.reduce(gcd, a_list))
    a_list.append(e)
    tmp.append(e)

print(max(res))

Fixed submission:
n = int(input())
a_list = list(map(int,input().split()))

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

res = []
l_gcd = [0]*(n+2)
r_gcd = [0]*(n+2)
for i in range(n+1):
    if i ==0:
        l_gcd[i] = 0
        r_gcd[n-i+1] = 0
        continue
    l_gcd[i] = gcd(l_gcd[i-1], a_list[i-1])
    r_gcd[n-i] = gcd(r_gcd[n-i+1], a_list[n-i])

for i in range(n+1):
    res.append(gcd(l_gcd[i],r_gcd[i+1]))

print(max(res))

Buggy python submission (verdict: Time Limit Exceeded):
import functools
n = int(input())
a_list = list(map(int,input().split()))

def gcd(m,n):
    x = max(m,n)
    y = min(m,n)
    if x in res or y in res:
        return y
    if x%y==0:
        return y
    else:
        while x%y!=0:
            x,y = y,x%y
        return y

res = []
tmp = []
for _ in range(n):
    e = a_list.pop(0)
    if e in tmp:
        continue
    res.append(functools.reduce(gcd, a_list))
    a_list.append(e)
    tmp.append(e)

print(max(res))

Fixed submission:
n = int(input())
a_list = list(map(int,input().split()))

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

res = []
l_gcd = [0]*(n+2)
r_gcd = [0]*(n+2)
for i in range(n+1):
    if i ==0:
        l_gcd[i] = 0
        r_gcd[n-i+1] = 0
        continue
    l_gcd[i] = gcd(l_gcd[i-1], a_list[i-1])
    r_gcd[n-i] = gcd(r_gcd[n-i+1], a_list[n-i])

for i in range(n+1):
    res.append(gcd(l_gcd[i],r_gcd[i+1]))

print(max(res))

Buggy python submission (verdict: Time Limit Exceeded):
import functools
n = int(input())
a_list = list(map(int,input().split()))

def gcd(m,n):
    x = max(m,n)
    y = min(m,n)
    if y in res:
        return y
    if x%y==0:
        return y
    else:
        while x%y!=0:
            x,y = y,x%y
        return y

res = []
tmp = []
for _ in range(n):
    e = a_list.pop(0)
    if e in tmp:
        continue
    res.append(functools.reduce(gcd, a_list))
    a_list.append(e)
    tmp.append(e)

print(max(res))

Fixed submission:
n = int(input())
a_list = list(map(int,input().split()))

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

res = []
l_gcd = [0]*(n+2)
r_gcd = [0]*(n+2)
for i in range(n+1):
    if i ==0:
        l_gcd[i] = 0
        r_gcd[n-i+1] = 0
        continue
    l_gcd[i] = gcd(l_gcd[i-1], a_list[i-1])
    r_gcd[n-i] = gcd(r_gcd[n-i+1], a_list[n-i])

for i in range(n+1):
    res.append(gcd(l_gcd[i],r_gcd[i+1]))

print(max(res))

Buggy python submission (verdict: Time Limit Exceeded):
import functools
n = int(input())
a_list = list(map(int,input().split()))

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

res = []
tmp = []
for _ in range(n):
    e = a_list.pop(0)
    if e in tmp:
        continue
    res.append(functools.reduce(gcd, a_list))
    a_list.append(e)
    tmp.append(e)

print(max(res))

Fixed submission:
n = int(input())
a_list = list(map(int,input().split()))

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

res = []
l_gcd = [0]*(n+2)
r_gcd = [0]*(n+2)
for i in range(n+1):
    if i ==0:
        l_gcd[i] = 0
        r_gcd[n-i+1] = 0
        continue
    l_gcd[i] = gcd(l_gcd[i-1], a_list[i-1])
    r_gcd[n-i] = gcd(r_gcd[n-i+1], a_list[n-i])

for i in range(n+1):
    res.append(gcd(l_gcd[i],r_gcd[i+1]))

print(max(res))

Buggy python submission (verdict: Time Limit Exceeded):
import functools
n = int(input())
a_list = list(map(int,input().split()))

def gcd(m,n):
    x = max(m,n)
    y = min(m,n)
    if x%y==0:
        return y
    else:
        while x%y!=0:
            x,y = y,x%y
        return y
res = []

for i in range(n):
    e = a_list.pop(0)
    res.append(functools.reduce(gcd, a_list))
    a_list.append(e)

print(max(res))

Fixed submission:
n = int(input())
a_list = list(map(int,input().split()))

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

res = []
l_gcd = [0]*(n+2)
r_gcd = [0]*(n+2)
for i in range(n+1):
    if i ==0:
        l_gcd[i] = 0
        r_gcd[n-i+1] = 0
        continue
    l_gcd[i] = gcd(l_gcd[i-1], a_list[i-1])
    r_gcd[n-i] = gcd(r_gcd[n-i+1], a_list[n-i])

for i in range(n+1):
    res.append(gcd(l_gcd[i],r_gcd[i+1]))

print(max(res))