Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())


import math
from functools import reduce
def gcd(numbers):
  return reduce (math.gcd, numbers)


ans = 0
a = list(map(int, input().split()))
for i in range(n):
  c = a[i]
  a.remove(c)
  ans = max(ans, gcd(a))
  a.insert(i, c)
#print(a)
  

print(ans)

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

import math
l_gcd = []
r_gcd = []

c = a[0]
for i in a[:-1]:
  c = math.gcd(c, i)
  l_gcd.append(c)
  
c = a[-1]
for j in a[1:][::-1]:
  c = math.gcd(c, j)
  r_gcd.append(c)
  
ans = max(r_gcd[-1], l_gcd[-1])
for r, l in zip(r_gcd[:-1], l_gcd[:-1][::-1]):
  c = math.gcd(r, l)
  ans = max(ans, c)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())


import math
from functools import reduce
def gcd(numbers):
  return reduce (math.gcd, numbers)


ans = 0
a = list(map(int, input().split()))
for i in range(n):
  c = a[i]
  a.remove(c)
  ans = max(ans, gcd(a))
  a.insert(i,c)
  

print(ans)

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

import math
l_gcd = []
r_gcd = []

c = a[0]
for i in a[:-1]:
  c = math.gcd(c, i)
  l_gcd.append(c)
  
c = a[-1]
for j in a[1:][::-1]:
  c = math.gcd(c, j)
  r_gcd.append(c)
  
ans = max(r_gcd[-1], l_gcd[-1])
for r, l in zip(r_gcd[:-1], l_gcd[:-1][::-1]):
  c = math.gcd(r, l)
  ans = max(ans, c)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())


import math
from functools import reduce
def gcd(numbers):
  return reduce (math.gcd, numbers)


res = []
a = list(map(int, input().split()))
for i in range(n):
  c = a[i]
  a.remove(c)
  res.append(gcd(a))
  a.insert(i,c)
  
ans = max(res)
print(ans)

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

import math
l_gcd = []
r_gcd = []

c = a[0]
for i in a[:-1]:
  c = math.gcd(c, i)
  l_gcd.append(c)
  
c = a[-1]
for j in a[1:][::-1]:
  c = math.gcd(c, j)
  r_gcd.append(c)
  
ans = max(r_gcd[-1], l_gcd[-1])
for r, l in zip(r_gcd[:-1], l_gcd[:-1][::-1]):
  c = math.gcd(r, l)
  ans = max(ans, c)
print(ans)

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

res = []
ans = []
x = 0
if n > 2:
  while x < math.factorial(n):
    c = random.sample(a, 2)
    if c not in res:
      res.append(c)
      x += 1 
      ans.append(math.gcd(c[0],c[1]))
  print(max(ans))
elif n == 2:
  while x < math.factorial(n)/2:
    c = random.sample(a, 2)
    if c not in res:
      res.append(c)
      x += 1 
      ans.append(math.gcd(c[0],c[1]))
  print(max(ans))

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

import math
l_gcd = []
r_gcd = []

c = a[0]
for i in a[:-1]:
  c = math.gcd(c, i)
  l_gcd.append(c)
  
c = a[-1]
for j in a[1:][::-1]:
  c = math.gcd(c, j)
  r_gcd.append(c)
  
ans = max(r_gcd[-1], l_gcd[-1])
for r, l in zip(r_gcd[:-1], l_gcd[:-1][::-1]):
  c = math.gcd(r, l)
  ans = max(ans, c)
print(ans)

Buggy python submission (verdict: Runtime Error):
import random
import math
n = int(input())
a = list(map(int, input().split()))

res = []
ans = []
x = 0
while x < math.factorial(n)/2:
  c = random.sample(a, 2)
  if c not in res:
    res.append(c)
    x += 1 
    ans.append(math.gcd(c[0],c[1]))
print(max(ans))

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

import math
l_gcd = []
r_gcd = []

c = a[0]
for i in a[:-1]:
  c = math.gcd(c, i)
  l_gcd.append(c)
  
c = a[-1]
for j in a[1:][::-1]:
  c = math.gcd(c, j)
  r_gcd.append(c)
  
ans = max(r_gcd[-1], l_gcd[-1])
for r, l in zip(r_gcd[:-1], l_gcd[:-1][::-1]):
  c = math.gcd(r, l)
  ans = max(ans, c)
print(ans)