Buggy python submission (verdict: Runtime Error):
#include <iostream>
using namespace std;

int gcd(int a, int b);

int main() {
    int N; cin >> N;
    int A[N]; for (int i = 0; i < N; i++) cin >> A[i];
    int left, right, max = 0;
    for (int n = 0; n < N; n++) {
        left = 0;
        right = 0;
        for (int i = 0; i < n; i++) left = gcd(left, A[i]);
        for (int i = N-1; i > n; i--) right = gcd(right, A[i]);
        if (gcd(left, right) > max) max = gcd(left, right);
    }
    cout << max << endl;
}

int gcd(int a, int b) {
    if (a < b) swap(a, b);
    if (b == 0) return a;
    int r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}


Fixed submission:
from fractions import gcd


def main():
    N = int(input())
    A = list(map(int, input().split()))
    left = [0] * N
    right = [0] * N
    for i in range(1, N):
        left[i] = gcd(left[i-1], A[i-1])
        right[-1-i] = gcd(right[-i], A[-i])
    gcds = []
    for i in range(N):
        gcds.append(gcd(left[i], right[i]))
    print(max(gcds))


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import fractions
from functools import reduce
from copy import copy


def main():
    N = int(input())
    A = list(map(int, input().split()))
    gcds = []
    for i in range(N):
        if i == 0:
            gcds.append(gcd(*A[i+1:]))
        elif i == N-1:
            gcds.append(gcd(*A[:i]))
        else:
            gcds.append(gcd(gcd(*A[:i]), gcd(*A[i+1:])))
    print(max(gcds))


def gcd(*nums):
    return reduce(fractions.gcd, nums)


if __name__ == '__main__':
    main()


Fixed submission:
from fractions import gcd


def main():
    N = int(input())
    A = list(map(int, input().split()))
    left = [0] * N
    right = [0] * N
    for i in range(1, N):
        left[i] = gcd(left[i-1], A[i-1])
        right[-1-i] = gcd(right[-i], A[-i])
    gcds = []
    for i in range(N):
        gcds.append(gcd(left[i], right[i]))
    print(max(gcds))


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import fractions
from functools import reduce
from copy import copy


def main():
    N = int(input())
    A = list(map(int, input().split()))
    gcds = []
    for i in range(N):
        A_ = copy(A)
        A_.pop(i)
        gcds.append(gcd(*A_))
    print(max(gcds))


def gcd(*nums):
    return reduce(fractions.gcd, nums)


if __name__ == '__main__':
    main()


Fixed submission:
from fractions import gcd


def main():
    N = int(input())
    A = list(map(int, input().split()))
    left = [0] * N
    right = [0] * N
    for i in range(1, N):
        left[i] = gcd(left[i-1], A[i-1])
        right[-1-i] = gcd(right[-i], A[-i])
    gcds = []
    for i in range(N):
        gcds.append(gcd(left[i], right[i]))
    print(max(gcds))


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import math
import fractions
from functools import reduce
from copy import copy

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

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

gcds = []
for i in range(N):
    A_ = copy(A)
    A_.pop(i)
    gcds.append(gcd(*A_))

print(max(gcds))


Fixed submission:
from fractions import gcd


def main():
    N = int(input())
    A = list(map(int, input().split()))
    left = [0] * N
    right = [0] * N
    for i in range(1, N):
        left[i] = gcd(left[i-1], A[i-1])
        right[-1-i] = gcd(right[-i], A[-i])
    gcds = []
    for i in range(N):
        gcds.append(gcd(left[i], right[i]))
    print(max(gcds))


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
import math
import fraction
from functools import reduce
from copy import copy

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

def gcd(*numbers):
    return reduce(fraction.gcd, numbers)

gcds = []
for i in range(N):
    A_ = copy(A)
    A_.pop(i)
    gcds.append(gcd(*A_))

print(max(gcds))


Fixed submission:
from fractions import gcd


def main():
    N = int(input())
    A = list(map(int, input().split()))
    left = [0] * N
    right = [0] * N
    for i in range(1, N):
        left[i] = gcd(left[i-1], A[i-1])
        right[-1-i] = gcd(right[-i], A[-i])
    gcds = []
    for i in range(N):
        gcds.append(gcd(left[i], right[i]))
    print(max(gcds))


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce
from copy import copy

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

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

gcds = []
for i in range(N):
    A_ = copy(A)
    A_.pop(i)
    gcds.append(gcd(*A_))

print(max(gcds))


Fixed submission:
from fractions import gcd


def main():
    N = int(input())
    A = list(map(int, input().split()))
    left = [0] * N
    right = [0] * N
    for i in range(1, N):
        left[i] = gcd(left[i-1], A[i-1])
        right[-1-i] = gcd(right[-i], A[-i])
    gcds = []
    for i in range(N):
        gcds.append(gcd(left[i], right[i]))
    print(max(gcds))


if __name__ == '__main__':
    main()