Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

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

divisors = []
for i in range(n):
    for j in range(1, int(a[i] ** 0.5) + 1):
        if a[i] % j == 0:
            divisors.append(j)
            if j != a[i] // j:
                divisors.append(a[i] // j)

d = Counter(divisors)
ans = [k for k, v in d.items() if v >= n - 1]
print(max(ans))

Fixed submission:
from fractions import gcd

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

left = [0 for _ in range(n + 1)]
right = [0 for _ in range(n + 1)]
for i in range(n):
    left[i + 1] = gcd(left[i], a[i])

for i in reversed(range(n)):
    right[i] = gcd(right[i + 1], a[i])

ans = 0
for i in range(n):
    l = left[i]
    r = right[i+1]
    ans = max(ans, gcd(l, r))

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
import itertools

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

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

div_l = []
for i in range(n):
    div_l.append(make_divisors(a[i]))

div = list(itertools.chain.from_iterable(div_l))
dict = Counter(div)
ans = [k for k, v in dict.items() if v >= n - 1]
print(max(ans))


Fixed submission:
from fractions import gcd

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

left = [0 for _ in range(n + 1)]
right = [0 for _ in range(n + 1)]
for i in range(n):
    left[i + 1] = gcd(left[i], a[i])

for i in reversed(range(n)):
    right[i] = gcd(right[i + 1], a[i])

ans = 0
for i in range(n):
    l = left[i]
    r = right[i+1]
    ans = max(ans, gcd(l, r))

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
import itertools

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

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

div_l = []
for i in range(n):
    div_l.append(make_divisors(a[i]))

div = list(itertools.chain.from_iterable(div_l))
dict = Counter(div)
ans = [k for k, v in dict.items() if v >= n - 1]
print(max(ans))


Fixed submission:
from fractions import gcd

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

left = [0 for _ in range(n + 1)]
right = [0 for _ in range(n + 1)]
for i in range(n):
    left[i + 1] = gcd(left[i], a[i])

for i in reversed(range(n)):
    right[i] = gcd(right[i + 1], a[i])

ans = 0
for i in range(n):
    l = left[i]
    r = right[i+1]
    ans = max(ans, gcd(l, r))

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

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)
    return divisors

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

div_l = []
for i in range(n):
    for j in make_divisors(a[i]):
        div_l.append(j)

dict = Counter(div_l)
ans = [k for k, v in dict.items() if v >= n - 1]
print(max(ans))

Fixed submission:
from fractions import gcd

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

left = [0 for _ in range(n + 1)]
right = [0 for _ in range(n + 1)]
for i in range(n):
    left[i + 1] = gcd(left[i], a[i])

for i in reversed(range(n)):
    right[i] = gcd(right[i + 1], a[i])

ans = 0
for i in range(n):
    l = left[i]
    r = right[i+1]
    ans = max(ans, gcd(l, r))

print(ans)