Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce
from fractions import gcd
N = int(input())
A = [int(i) for i in input().split()]
ans = 0
for i in range(N):
  if i < N-1:
    a = A[i]
    A[i] = A[i+1]
  else:
    A[i] = A[0]
  ans = max(ans, reduce(gcd,A))
  A[i] = a
print(ans)

Fixed submission:
import fractions
from functools import reduce
n = int(input())
a = list(map(int,input().split()))
left = [0] * (n + 1)
right = [0] * (n + 1)
for i in range(n):
    left[i + 1] = (fractions.gcd(left[i],a[i]))
    right[n - i - 1] = (fractions.gcd(right[n - i],a[n - 1 - i]))
ans = 0
for i in range(n):
    ans = max(ans,fractions.gcd(left[i],right[i + 1]))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce
from fractions import gcd
N = int(input())
A = [int(i) for i in input().split()]
ans = 0
for i in range(N):
  L = A[:i]
  R = A[i+1:]
  ans = max(ans, reduce(gcd,L+R))
print(ans)

Fixed submission:
import fractions
from functools import reduce
n = int(input())
a = list(map(int,input().split()))
left = [0] * (n + 1)
right = [0] * (n + 1)
for i in range(n):
    left[i + 1] = (fractions.gcd(left[i],a[i]))
    right[n - i - 1] = (fractions.gcd(right[n - i],a[n - 1 - i]))
ans = 0
for i in range(n):
    ans = max(ans,fractions.gcd(left[i],right[i + 1]))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce
from fractions import gcd
N = int(input())
A = [int(i) for i in input().split()]
ans = 0
for i in range(N):
  L = A[:i]
  R = A[i+1:]
  ans = max(ans, reduce(gcd,L+R))
print(ans)

Fixed submission:
import fractions
from functools import reduce
n = int(input())
a = list(map(int,input().split()))
left = [0] * (n + 1)
right = [0] * (n + 1)
for i in range(n):
    left[i + 1] = (fractions.gcd(left[i],a[i]))
    right[n - i - 1] = (fractions.gcd(right[n - i],a[n - 1 - i]))
ans = 0
for i in range(n):
    ans = max(ans,fractions.gcd(left[i],right[i + 1]))
print(ans)

Buggy python submission (verdict: Runtime Error):
from functools import reduce
from fractions import gcd
n = int(input())
A = list(map(int,input().split()))
B = A.copy()
ans1 = reduce(gcd, A)
for i in range(n-1):
  A.pop(i)
  ans = reduce(gcd, A)
  A = B
  if ans > ans1: 
    print(ans)
    exit()
print(ans1)

Fixed submission:
import fractions
from functools import reduce
n = int(input())
a = list(map(int,input().split()))
left = [0] * (n + 1)
right = [0] * (n + 1)
for i in range(n):
    left[i + 1] = (fractions.gcd(left[i],a[i]))
    right[n - i - 1] = (fractions.gcd(right[n - i],a[n - 1 - i]))
ans = 0
for i in range(n):
    ans = max(ans,fractions.gcd(left[i],right[i + 1]))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import fractions
from functools import reduce
import copy
def gcd(numbers):
    return reduce(fractions.gcd, numbers)
a = int(input())
b = list(map(int, input().split()))
c = []
d = copy.deepcopy(b)
for i in range(a):
  b = copy.deepcopy(d)
  if a == 2:
    c.append(max(b))
  elif a >= 3:
    b.pop(i)
    c.append(gcd(b))
if a <= 3:
  print(max(c))
elif a > 3:
  if max(c) == 1:
    print(1)
  else:
    print(max(c))

Fixed submission:
import fractions
from functools import reduce
n = int(input())
a = list(map(int,input().split()))
left = [0] * (n + 1)
right = [0] * (n + 1)
for i in range(n):
    left[i + 1] = (fractions.gcd(left[i],a[i]))
    right[n - i - 1] = (fractions.gcd(right[n - i],a[n - 1 - i]))
ans = 0
for i in range(n):
    ans = max(ans,fractions.gcd(left[i],right[i + 1]))
print(ans)