Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import math
import copy

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


def calc_gcd(arr):
    if len(arr) <= 0:
        return 0
    arr2 = copy.copy(arr)
    return math.gcd(calc_gcd(arr2[:len(arr)-1]), arr[-1])


gcd_array = []
for i in range(N):
    B = copy.copy(A)
    B.pop(i)
    gcd_array.append(calc_gcd(B))

print(max(gcd_array))

Fixed submission:
# -*- coding: utf-8 -*-
import fractions

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


gcd = fractions.gcd


left = [0] * N
right = [0] * N
for i in range(N):
    if i == 0:
        left[0] = A[0]
        right[N-1] = A[-1]
        continue

    left[i] = gcd(left[i-1], A[i])
    right[N-i-1] = gcd(right[N-i], A[N-i-1])

max_gcd = right[1]
for i in range(N):
    if i == 0:
        continue
    elif i == N - 1:
        if max_gcd < left[-2]:
            max_gcd = left[-2]
    else:
        target = gcd(left[i-1], right[i+1])
        if max_gcd < target:
            max_gcd = target

print(max_gcd)

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import copy

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


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


def calc_gcd(arr):
    if len(arr) <= 0:
        return 0
    arr2 = copy.copy(arr)
    return gcd(calc_gcd(arr2[:len(arr)-1]), arr[-1])


ans = 1

B = copy.copy(A)

gcd_array = []
for i in range(N):
    B.pop(i)
    gcd_array.append(calc_gcd(B))
    B = copy.copy(A)

print(max(gcd_array))

Fixed submission:
# -*- coding: utf-8 -*-
import fractions

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


gcd = fractions.gcd


left = [0] * N
right = [0] * N
for i in range(N):
    if i == 0:
        left[0] = A[0]
        right[N-1] = A[-1]
        continue

    left[i] = gcd(left[i-1], A[i])
    right[N-i-1] = gcd(right[N-i], A[N-i-1])

max_gcd = right[1]
for i in range(N):
    if i == 0:
        continue
    elif i == N - 1:
        if max_gcd < left[-2]:
            max_gcd = left[-2]
    else:
        target = gcd(left[i-1], right[i+1])
        if max_gcd < target:
            max_gcd = target

print(max_gcd)

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import math
import copy

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

B = copy.copy(A)

gcd_array = []
for i in range(N):
    B.pop(i)
    C = copy.copy(B[1:])
    C.append(B[0])
    gcd = 100000000000000000000
    for b, c in zip(B, C):
        tmp = math.gcd(b, c)
        if tmp < gcd:
            gcd = tmp
    gcd_array.append(gcd)

    B = copy.copy(A)
print(max(gcd_array))

Fixed submission:
# -*- coding: utf-8 -*-
import fractions

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


gcd = fractions.gcd


left = [0] * N
right = [0] * N
for i in range(N):
    if i == 0:
        left[0] = A[0]
        right[N-1] = A[-1]
        continue

    left[i] = gcd(left[i-1], A[i])
    right[N-i-1] = gcd(right[N-i], A[N-i-1])

max_gcd = right[1]
for i in range(N):
    if i == 0:
        continue
    elif i == N - 1:
        if max_gcd < left[-2]:
            max_gcd = left[-2]
    else:
        target = gcd(left[i-1], right[i+1])
        if max_gcd < target:
            max_gcd = target

print(max_gcd)