Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
N = int(input())
A = [int(x) for x in input().split()]
import fractions
from functools import reduce

def gcd(*numbers):
    return abs(reduce(fractions.gcd, numbers))
ans = 0
for i in range(N):
    temp = A[:i] + A[i+1:]
    ans = max(ans, gcd(*temp))
print(ans)


Fixed submission:
import sys
input = sys.stdin.readline
N = int(input())
A = [int(x) for x in input().split()]
import fractions
from functools import reduce

def gcd(*numbers):
    return abs(reduce(fractions.gcd, numbers))

L = [A[0]]
R = [A[-1]]
A_R = A[::-1]
for i in range(1, N):
    L.append(fractions.gcd(L[-1], A[i]))
    R.append(fractions.gcd(R[-1], A_R[i]))
R = R[::-1]
ans = R[1]
R.append(0)
for i in range(N - 1):
    ans = max(ans, fractions.gcd(L[i],R[i+2]))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
N = int(input())
A = [int(x) for x in input().split()]
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors
div = []
for i in A:
    div += make_divisors(i)
from collections import Counter
c = Counter(div)
ans = 0
for i in c.keys():
    if c[i] >= N - 1:
        ans = max(ans, i)
print(ans)

Fixed submission:
import sys
input = sys.stdin.readline
N = int(input())
A = [int(x) for x in input().split()]
import fractions
from functools import reduce

def gcd(*numbers):
    return abs(reduce(fractions.gcd, numbers))

L = [A[0]]
R = [A[-1]]
A_R = A[::-1]
for i in range(1, N):
    L.append(fractions.gcd(L[-1], A[i]))
    R.append(fractions.gcd(R[-1], A_R[i]))
R = R[::-1]
ans = R[1]
R.append(0)
for i in range(N - 1):
    ans = max(ans, fractions.gcd(L[i],R[i+2]))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
N = int(input())
A = [int(x) for x in input().split()]
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors
div = []
for i in A:
    div += make_divisors(i)
from collections import Counter
c = Counter(div)
ans = 0
for i in c.keys():
    if c[i] >= N - 1:
        ans = max(ans, i)
print(ans)

Fixed submission:
import sys
input = sys.stdin.readline
N = int(input())
A = [int(x) for x in input().split()]
import fractions
from functools import reduce

def gcd(*numbers):
    return abs(reduce(fractions.gcd, numbers))

L = [A[0]]
R = [A[-1]]
A_R = A[::-1]
for i in range(1, N):
    L.append(fractions.gcd(L[-1], A[i]))
    R.append(fractions.gcd(R[-1], A_R[i]))
R = R[::-1]
ans = R[1]
R.append(0)
for i in range(N - 1):
    ans = max(ans, fractions.gcd(L[i],R[i+2]))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
N = int(input())
A = [int(x) for x in input().split()]
import fractions
from functools import reduce

def gcd(*numbers):
    return abs(reduce(fractions.gcd, numbers))
ans = 0
for i in range(N):
    temp = A[:i] + A[i+1:]
    ans = max(ans, gcd(*temp))
print(ans)

Fixed submission:
import sys
input = sys.stdin.readline
N = int(input())
A = [int(x) for x in input().split()]
import fractions
from functools import reduce

def gcd(*numbers):
    return abs(reduce(fractions.gcd, numbers))

L = [A[0]]
R = [A[-1]]
A_R = A[::-1]
for i in range(1, N):
    L.append(fractions.gcd(L[-1], A[i]))
    R.append(fractions.gcd(R[-1], A_R[i]))
R = R[::-1]
ans = R[1]
R.append(0)
for i in range(N - 1):
    ans = max(ans, fractions.gcd(L[i],R[i+2]))
print(ans)