Buggy python submission (verdict: Time Limit Exceeded):
import fractions

n = int(input())
lst = list(map(int, input().split()))

ans = 0
lst_l = [lst[0]]
lst_r = [lst[n-1]]

for i in range(n-1):
  lst_l.append(fractions.gcd(lst_l[-1], lst[i + 1]))
  lst_r.insert(0, fractions.gcd(lst_r[0], lst[n-2-i]))

for i in range(n-2):
  x = fractions.gcd(lst_l[i], lst_r[i+2])
  if ans < x:
    ans = x
print(max(ans,lst_r[1],lst_l[-2]))

Fixed submission:
import fractions

n = int(input())
lst = list(map(int, input().split()))

ans = 0
left = [0]
right = [0] * (n+1)

for i in range(n):
  left.append(fractions.gcd(left[-1],lst[i]))
  right[n-1-i] = fractions.gcd(right[n-i],lst[n-1-i])

for i in range(n):
  x = fractions.gcd(left[i], right[i+1])
  if ans < x:
    ans = x
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import fractions

n = int(input())
lst = list(map(int, input().split()))

'''def gcd(a, b):
  if b == 0:
    return a
  else:
    return gcd(b, a%b)'''

ans = []
lst_l = [lst[0]]
lst_r = [lst[n-1]]
for i in range(n-1):
  lst_l.append(fractions.gcd(lst_l[-1], lst[i + 1]))
  lst_r.insert(0, fractions.gcd(lst_r[0], lst[n-2-i]))

ans.append(lst_r[1])
for i in range(n-2):
  ans.append(fractions.gcd(lst_l[i], lst_r[i+2]))
ans.append(lst_l[-2])

print(max(ans))

Fixed submission:
import fractions

n = int(input())
lst = list(map(int, input().split()))

ans = 0
left = [0]
right = [0] * (n+1)

for i in range(n):
  left.append(fractions.gcd(left[-1],lst[i]))
  right[n-1-i] = fractions.gcd(right[n-i],lst[n-1-i])

for i in range(n):
  x = fractions.gcd(left[i], right[i+1])
  if ans < x:
    ans = x
print(ans)

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

def gcd(a, b):
  if b == 0:
    return a
  else:
    return gcd(b, a%b)
def gcd_array(a):#aは配列
  return reduce(gcd, a)

ans = []
lst_l = [lst[0]]
lst_r = [lst[n-1]]
for i in range(n-1):
  lst_l.append(gcd(lst_l[-1], lst[i + 1]))
  lst_r.insert(0, gcd(lst_r[0], lst[n-2-i]))

ans.append(lst_r[1])
for i in range(n-2):
  ans.append(gcd(lst_l[i], lst_r[i+2]))
ans.append(lst_l[-2])

print(max(ans))

Fixed submission:
import fractions

n = int(input())
lst = list(map(int, input().split()))

ans = 0
left = [0]
right = [0] * (n+1)

for i in range(n):
  left.append(fractions.gcd(left[-1],lst[i]))
  right[n-1-i] = fractions.gcd(right[n-i],lst[n-1-i])

for i in range(n):
  x = fractions.gcd(left[i], right[i+1])
  if ans < x:
    ans = x
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import copy
from functools import reduce

n = int(input())
lst = list(map(int, input().split()))

def gcd(a, b):
  if b == 0:
    return a
  else:
    return gcd(b, a%b)
def gcd_array(a):#aは配列
  return reduce(gcd, a)

ans = 0
lst_t = []
for i in range(n):
  lst_t = copy.deepcopy(lst)
  del lst_t[i]
  x = gcd_array(lst_t)
  if ans < x:
    ans = x
  
print(ans)

Fixed submission:
import fractions

n = int(input())
lst = list(map(int, input().split()))

ans = 0
left = [0]
right = [0] * (n+1)

for i in range(n):
  left.append(fractions.gcd(left[-1],lst[i]))
  right[n-1-i] = fractions.gcd(right[n-i],lst[n-1-i])

for i in range(n):
  x = fractions.gcd(left[i], right[i+1])
  if ans < x:
    ans = x
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import copy
from functools import reduce

n = int(input())
lst = list(map(int, input().split()))

def gcd(a, b):
  if b == 0:
    return a
  else:
    return gcd(b, a%b)
def gcd_array(a):#aは配列
  return reduce(gcd, a)

ans = []
lst_t = []
for i in range(n):
  lst_t = copy.deepcopy(lst)
  del lst_t[i]
  x = gcd_array(lst_t)
  ans.append(x)
  
print(max(ans))

Fixed submission:
import fractions

n = int(input())
lst = list(map(int, input().split()))

ans = 0
left = [0]
right = [0] * (n+1)

for i in range(n):
  left.append(fractions.gcd(left[-1],lst[i]))
  right[n-1-i] = fractions.gcd(right[n-i],lst[n-1-i])

for i in range(n):
  x = fractions.gcd(left[i], right[i+1])
  if ans < x:
    ans = x
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import copy

n = int(input())
lst = list(map(int, input().split()))

def gcd(a, b):
  if b == 0:
    return a
  else:
    return gcd(b, a%b)
def gcd_array(a):#aは配列
  ans = a[0]
  for i in range(len(a)-1):
    ans = gcd(ans, a[i+1])
  return ans

ans = []
lst_t = []
for i in range(n):
  lst_t = copy.deepcopy(lst)
  del lst_t[i]
  x = gcd_array(lst_t)
  ans.append(x)
  
print(max(ans))

Fixed submission:
import fractions

n = int(input())
lst = list(map(int, input().split()))

ans = 0
left = [0]
right = [0] * (n+1)

for i in range(n):
  left.append(fractions.gcd(left[-1],lst[i]))
  right[n-1-i] = fractions.gcd(right[n-i],lst[n-1-i])

for i in range(n):
  x = fractions.gcd(left[i], right[i+1])
  if ans < x:
    ans = x
print(ans)