Buggy python submission (verdict: Runtime Error):
def gcd(x, y):
    """
    ユークリッドの互除法を用いて最大公約数を求める
    """
    if not x:
        return y
    return gcd(y % x, x)

def dfs(L, A):
    if not len(L):
        return A
    return gcd(dfs(L[:-1], L[-1]), A)

def get_M_i(A, i):
    """
    i番目のAを取り除いて得られる最大公約数を返す
    """
    L = dfs(A[:i-1], A[i-1]) if i > 0 else 0
    R = dfs(A[i+1:-1], A[-1]) if i+1 < len(A) else 0
    return gcd(L, R)

if __name__ == "__main__":
    N = int(input())
    A = list(map(int, input().split()))

    if N == 2:
        print(max(A))

    else:
        # i番目のMの値はi番目のAを取り除いて得られるN-1個の整数の最大公約数
        M = [0 for _ in range(N)]

        for i in range(N):
            M[i] = get_M_i(A, i)

        print(max(M))

Fixed submission:
from fractions import gcd 

N = int(input())
A = [int(i) for i in input().split()]

# Lを埋める
L = [0 for _ in range(N+1)]
for i in range(1, N+1):
    if not L[i-1]:
        L[i] = A[i-1]
    else: 
        L[i] = gcd(L[i-1], A[i-1])

# Rを埋める
R = [0 for _ in range(N+1)]
for i in range(1, N+1)[::-1]:
    if not R[i]:
        R[i-1] = A[i-1] 
    else:
        R[i-1] = gcd(R[i], A[i-1])

# Mを埋める
M = [0 for _ in range(N)]
for i in range(N):
    if not L[i]:
        M[i] = R[i+1]
    elif not R[i]:
        M[i] = L[i]
    else: 
        M[i] = gcd(L[i], R[i+1])

print(max(M))

Buggy python submission (verdict: Runtime Error):
def gcd(x, y):
    """
    ユークリッドの互除法を用いて最大公約数を求める
    """
    if not x:
        return y
    return gcd(y % x, x)

def dfs(L, A):
    if not len(L):
        return A
    return gcd(dfs(L[:-1], L[-1]), A)

def get_M_i(A, i):
    """
    i番目のAを取り除いて得られる最大公約数を返す
    """
    L = dfs(A[:i-1], A[i-1]) if i > 0 else 0
    R = dfs(A[i+1:-1], A[-1]) if i+1 < len(A) else 0
    return gcd(L, R)

if __name__ == "__main__":
    N = int(input())
    A = list(map(int, input().split()))

    # i番目のMの値はi番目のAを取り除いて得られるN-1個の整数の最大公約数
    M = [0 for _ in range(N)]

    for i in range(N):
        M[i] = get_M_i(A, i)

    print(max(M))

Fixed submission:
from fractions import gcd 

N = int(input())
A = [int(i) for i in input().split()]

# Lを埋める
L = [0 for _ in range(N+1)]
for i in range(1, N+1):
    if not L[i-1]:
        L[i] = A[i-1]
    else: 
        L[i] = gcd(L[i-1], A[i-1])

# Rを埋める
R = [0 for _ in range(N+1)]
for i in range(1, N+1)[::-1]:
    if not R[i]:
        R[i-1] = A[i-1] 
    else:
        R[i-1] = gcd(R[i], A[i-1])

# Mを埋める
M = [0 for _ in range(N)]
for i in range(N):
    if not L[i]:
        M[i] = R[i+1]
    elif not R[i]:
        M[i] = L[i]
    else: 
        M[i] = gcd(L[i], R[i+1])

print(max(M))

Buggy python submission (verdict: Runtime Error):
def gcd(x, y):
    """
    ユークリッドの互除法を用いて最大公約数を求める
    """
    if not x:
        return y
    return gcd(y % x, x)

def dfs(L, A):
    if not len(L):
        return A
    return gcd(dfs(L[:-1], L[-1]), A)

def get_M_i(A, i):
    """
    i番目のAを取り除いて得られる最大公約数を返す
    """
    L = dfs(A[:i-1], A[i-1]) if i > 0 else 0
    R = dfs(A[i+1:-1], A[-1]) if i < len(A) else 0
    return gcd(L, R)

if __name__ == "__main__":
    N = int(input())
    A = list(map(int, input().split()))

    # i番目のMの値はi番目のAを取り除いて得られるN-1個の整数の最大公約数
    M = [0 for _ in range(N)]

    for i in range(N):
        M[i] = get_M_i(A, i)

    print(max(M))

Fixed submission:
from fractions import gcd 

N = int(input())
A = [int(i) for i in input().split()]

# Lを埋める
L = [0 for _ in range(N+1)]
for i in range(1, N+1):
    if not L[i-1]:
        L[i] = A[i-1]
    else: 
        L[i] = gcd(L[i-1], A[i-1])

# Rを埋める
R = [0 for _ in range(N+1)]
for i in range(1, N+1)[::-1]:
    if not R[i]:
        R[i-1] = A[i-1] 
    else:
        R[i-1] = gcd(R[i], A[i-1])

# Mを埋める
M = [0 for _ in range(N)]
for i in range(N):
    if not L[i]:
        M[i] = R[i+1]
    elif not R[i]:
        M[i] = L[i]
    else: 
        M[i] = gcd(L[i], R[i+1])

print(max(M))