Buggy python submission (verdict: Runtime Error):
from math import gcd
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines


class SegmentTree:
    # セグ木は 1-indexed
    def __init__(self, n, initial=0):
        """
        n: 配列の大きさ
        initial: 単位元 (RMQでは大きな値)
        """
        self.offset = 2**(n-1).bit_length()  # 2進数表記の長さ
        self.initial = initial
        self.seg = [self.initial] * (2 * self.offset)
        

    def build(self, A):
        """
        A: 処理したい配列
        """
        for i, a in enumerate(A, start=self.offset):
            self.seg[i] = a
        for i in range(self.offset-1,0,-1):
            self.seg[i] = gcd(self.seg[i<<1] ,self.seg[(i<<1)+1])

            
    def update(self, k, a):
        """
        k番目の値をaに変更
        """
        k += self.offset
        self.seg[k] = a
        while k:
            k >>= 1
            self.seg[k] = gcd(self.seg[k<<1], self.seg[(k<<1)+1])

            
    def query(self, a, b):
        """
        区間[a, b)に対して最小公倍数を求める
        """
        a += self.offset
        b += self.offset - 1 
        res = self.initial
        while a < b:
            if a & 1:  # 兄弟の右なら
                res = gcd(res, self.seg[a])
                a += 1
            if not b & 1:  # 兄弟の左なら
                res = gcd(res, self.seg[b])
                b -= 1
            a >>= 1
            b >>= 1
        
        if a == b:
            res = gcd(res, self.seg[a])
        
        return res


if __name__ == "__main__":
    N = int(readline())
    A = [int(i) for i in readline().split()]
    seg = SegmentTree(N)
    seg.build(A)

    ans = seg.query(1, N)
    for i in range(N-2):
        tmp = gcd(seg.query(0, i+1), seg.query(i+2, N))
        ans = max(ans, tmp)
    ans = max(ans, seg.query(0, N-1))

    print(ans)

Fixed submission:
from fractions import gcd

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

L = []
R = []
L.append(a[0])
R.append(a[-1])

for i in range(N-2):
    L.append(gcd(L[-1], a[i+1]))
    R.append(gcd(R[-1], a[-(i+2)]))

ans = max(L[-1], R[-1])
for i in range(N-2):
    tmp = gcd(L[i], R[-(i+2)])
    if tmp > ans:
        ans = tmp

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import fractions

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

ans = []
for i in range(N):
    dpL = []
    L = a[:i]
    if len(L)>=1:
        dpL.append(L[0])
        for j,left in enumerate(L):
            dpL.append(fractions.gcd(dpL[j],left))
#    print(dpL)
    
    dpR = []
    R = a[i+1:]
    if len(R)>=1:
        dpR.append(R[0])
        for j,right in enumerate(R):
            dpR.append(fractions.gcd(dpR[j],right))
   # print(dpR)
   
    if dpL == []:
        ans.append(min(dpR))
    elif dpR == []:
        ans.append(min(dpL))
    else:
        ans.append(fractions.gcd(dpL[len(dpL)-1],dpR[len(dpR)-1]))

print(max(ans))


Fixed submission:
from fractions import gcd

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

L = []
R = []
L.append(a[0])
R.append(a[-1])

for i in range(N-2):
    L.append(gcd(L[-1], a[i+1]))
    R.append(gcd(R[-1], a[-(i+2)]))

ans = max(L[-1], R[-1])
for i in range(N-2):
    tmp = gcd(L[i], R[-(i+2)])
    if tmp > ans:
        ans = tmp

print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())

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

count=0
ans=0

for i in range(N):
    if a[i]<0:
        count+=1
    	a[i]=abs(a[i])

if count%2==0:
    ans=sum(a)

else:
    a.sort()
    ans=sum(a)-a[0]*2

print(ans)


Fixed submission:
from fractions import gcd

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

L = []
R = []
L.append(a[0])
R.append(a[-1])

for i in range(N-2):
    L.append(gcd(L[-1], a[i+1]))
    R.append(gcd(R[-1], a[-(i+2)]))

ans = max(L[-1], R[-1])
for i in range(N-2):
    tmp = gcd(L[i], R[-(i+2)])
    if tmp > ans:
        ans = tmp

print(ans)