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

def gcd(x, y):
  if y == 0:
    return x
  else:
    return gcd(y, x % y)

def cal(array):
  while(len(array) > 1):
    a = array.pop(0)
    b = array.pop(0)
    array.insert(0, gcd(a, b))
  return array[0]

def bSort(a):
  for i in range(len(a)):
    for j in range(len(a)-1, i, -1):
      if a[j] < a[j-1]:
        a[j], a[j-1] = a[j-1], a[j]

  return a

n = int(input())
a = list(map(lambda x: int(x), input().split()))
a = bSort(a)
answer_list = []

for i in range(int(n)):
  copy_a = copy.copy(a)
  copy_pop_a = copy_a.pop(i)
  heapq.heappush(answer_list, -(cal(copy_a)))

answer = -heapq.heappop(answer_list)
print(answer)


Fixed submission:
import copy
import heapq
import fractions

N = int(input())
A = list(map(int, input().split()))

gcd_l = [0]
gcd_r = [0]

for i in range(N):
  gcd_l.append(fractions.gcd(gcd_l[i], A[i]))
  gcd_r.append(fractions.gcd(gcd_r[i], A[-(i+1)]))

gcd_r = gcd_r[::-1]
ans = []

for i in range(N):
  ans.append(fractions.gcd(gcd_l[i], gcd_r[i+1]))

print(max(ans))

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

def gcd(x, y):
  if y == 0:
    return x
  else:
    return gcd(y, x % y)

def cal(array):
  while(len(array) > 1):
    a = array.pop(0)
    b = array.pop(0)
    array.insert(0, gcd(a, b))
  return array[0]

def bSort(a):
  for i in range(len(a)):
    for j in range(len(a)-1, i, -1):
      if a[j] < a[j-1]:
        a[j], a[j-1] = a[j-1], a[j]

  return a

n = int(input())
a = list(map(lambda x: int(x), input().split()))


answer_list = []

for i in range(int(n)):
  copy_a = copy.copy(a)
  copy_pop_a = copy_a.pop(i)
  answer_list.insert(0, cal(copy_a))

answer = max(answer_list)

print(answer)


Fixed submission:
import copy
import heapq
import fractions

N = int(input())
A = list(map(int, input().split()))

gcd_l = [0]
gcd_r = [0]

for i in range(N):
  gcd_l.append(fractions.gcd(gcd_l[i], A[i]))
  gcd_r.append(fractions.gcd(gcd_r[i], A[-(i+1)]))

gcd_r = gcd_r[::-1]
ans = []

for i in range(N):
  ans.append(fractions.gcd(gcd_l[i], gcd_r[i+1]))

print(max(ans))

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

def gcd(x, y):
  if y == 0:
    return x
  else:
    return gcd(y, x % y)

def cal(array):
  while(len(array) > 1):
    a = int(array.pop(0))
    b = int(array.pop(0))
    array.append(gcd(a, b))
  return array[0]

n = int(input())
a = input().split()

answer_list = []

for i in range(int(n)):
  copy_a = copy.copy(a)
  copy_pop_a = copy_a.pop(i)
  answer_list.insert(0, cal(copy_a))

answer = max(answer_list)

print(answer)


Fixed submission:
import copy
import heapq
import fractions

N = int(input())
A = list(map(int, input().split()))

gcd_l = [0]
gcd_r = [0]

for i in range(N):
  gcd_l.append(fractions.gcd(gcd_l[i], A[i]))
  gcd_r.append(fractions.gcd(gcd_r[i], A[-(i+1)]))

gcd_r = gcd_r[::-1]
ans = []

for i in range(N):
  ans.append(fractions.gcd(gcd_l[i], gcd_r[i+1]))

print(max(ans))

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

def gcd(x, y):
  if y == 0:
    return x
  else:
    return gcd(y, x % y)

def cal(array):
  while(len(array) > 1):
    a = int(array.pop(0))
    b = int(array.pop(0))
    array.append(gcd(a, b))
  return array[0]

n = int(input())
a = input().split()

answer_list = []

for i in range(int(n)):
  copy_a = copy.copy(a)
  copy_pop_a = copy_a.pop(i)
  answer_list.append(cal(copy_a))

answer = max(answer_list)

print(answer)


Fixed submission:
import copy
import heapq
import fractions

N = int(input())
A = list(map(int, input().split()))

gcd_l = [0]
gcd_r = [0]

for i in range(N):
  gcd_l.append(fractions.gcd(gcd_l[i], A[i]))
  gcd_r.append(fractions.gcd(gcd_r[i], A[-(i+1)]))

gcd_r = gcd_r[::-1]
ans = []

for i in range(N):
  ans.append(fractions.gcd(gcd_l[i], gcd_r[i+1]))

print(max(ans))

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

def gcd(x, y):
  if y == 0:
    return x
  else:
    return gcd(y, x % y)

def cal(array):
  while(len(array) > 1):
    a = array.pop(0)
    b = array.pop(0)
    array.append(gcd(a, b))
  return array[0]

n = input()
a = input().split()
a = map(lambda x: int(x), a)

answer_list = []

for i in range(int(n)):
  copy_a = copy.copy(a)
  copy_pop_a = copy_a.pop(i)
  answer_list.append(cal(copy_a))

answer = max(answer_list)

print(answer)


Fixed submission:
import copy
import heapq
import fractions

N = int(input())
A = list(map(int, input().split()))

gcd_l = [0]
gcd_r = [0]

for i in range(N):
  gcd_l.append(fractions.gcd(gcd_l[i], A[i]))
  gcd_r.append(fractions.gcd(gcd_r[i], A[-(i+1)]))

gcd_r = gcd_r[::-1]
ans = []

for i in range(N):
  ans.append(fractions.gcd(gcd_l[i], gcd_r[i+1]))

print(max(ans))