Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split())).sort(reverse=True)

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

ans = 1
if n == 2:
    print(max(a))
else:
    for i in range(n // 10):
        b = a[:i] + a[i + 1:]
        element = gcd(b[0], b[1])
        if n == 3:
            ans = max(ans, element)
        else:
            for j in range(2, n - 1):
                element = gcd(element, b[j])
            ans = max(ans, element)
    print(ans)


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


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

ans = 1
if n == 2:
    print(max(a))
else:
    l = [0] * (n + 1)
    r = [0] * (n + 1)
    for i in range(1, n):
        l[i] = gcd(l[i - 1], a[i - 1])
        r[n - i] = gcd(r[n - i + 1], a[-i])
    for i in range(n):
        m = gcd(l[i], r[i + 1])
        ans = max(ans, m)
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

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

ans = 1
if n == 2:
    print(max(a))
else:
    for i in range(n):
        b = a[:i] + a[i + 1:]
        element = gcd(b[0], b[1])
        if n == 3:
            ans = max(ans, element)
        else:
            for j in range(2, n - 1):
                element = gcd(element, b[j])
            ans = max(ans, element)
    print(ans)


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


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

ans = 1
if n == 2:
    print(max(a))
else:
    l = [0] * (n + 1)
    r = [0] * (n + 1)
    for i in range(1, n):
        l[i] = gcd(l[i - 1], a[i - 1])
        r[n - i] = gcd(r[n - i + 1], a[-i])
    for i in range(n):
        m = gcd(l[i], r[i + 1])
        ans = max(ans, m)
    print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))

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

ans = 1
if n == 2:
    print(max(a))
else:
    for i in range(n):
        b = a[:i] + a[i + 1:]
        element = gcd(b[0], b[1])
        if n == 3:
            ans = max(ans, element)
        else:
            for j in range(2, n - 1):
                element = gcd(element, b[i])
            ans = max(ans, element)
    print(ans)


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


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

ans = 1
if n == 2:
    print(max(a))
else:
    l = [0] * (n + 1)
    r = [0] * (n + 1)
    for i in range(1, n):
        l[i] = gcd(l[i - 1], a[i - 1])
        r[n - i] = gcd(r[n - i + 1], a[-i])
    for i in range(n):
        m = gcd(l[i], r[i + 1])
        ans = max(ans, m)
    print(ans)

Buggy python submission (verdict: Runtime Error):
import math
n = int(input())
a = list(map(int, input().split()))

ans = 1
if n == 2:
    print(max(a))
else:
    for i in range(n):
        b = a[:i] + a[i + 1:]
        element = math.gcd(b[0], b[1])
        if n == 3:
            ans = max(ans, element)
        else:
            for j in range(2, n - 1):
                element = math.gcd(element, b[i])
            ans = max(ans, element)
    print(ans)


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


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

ans = 1
if n == 2:
    print(max(a))
else:
    l = [0] * (n + 1)
    r = [0] * (n + 1)
    for i in range(1, n):
        l[i] = gcd(l[i - 1], a[i - 1])
        r[n - i] = gcd(r[n - i + 1], a[-i])
    for i in range(n):
        m = gcd(l[i], r[i + 1])
        ans = max(ans, m)
    print(ans)

Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce
n = int(input())
a = list(map(int, input().split()))

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

ans = 1
for i in range(n):
    b = a[:i] + a[i + 1:]
    ans = max(ans, gcd_list(b))

print(ans)


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


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

ans = 1
if n == 2:
    print(max(a))
else:
    l = [0] * (n + 1)
    r = [0] * (n + 1)
    for i in range(1, n):
        l[i] = gcd(l[i - 1], a[i - 1])
        r[n - i] = gcd(r[n - i + 1], a[-i])
    for i in range(n):
        m = gcd(l[i], r[i + 1])
        ans = max(ans, m)
    print(ans)