Buggy python submission (verdict: Runtime Error):
import fractions

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

used={}
unused={}

def gcd(x,y):
    if x==-1 or y==-1:
        return max(x,y)
    return fractions.gcd(x,y)

def rec(i,x,f):
    if i+1==N:
        return x
    
    if f==1 and used.get(x,-2)>-2:
        return used[x]
    if f==0 and unused.get(x,-2)>-2:
        return unused[x]
    
    if f==0:
        unused[x]=rec(i+1,gcd(x,A[i+1]),0)
        used[x]=rec(i+1,x,1)
        return max(unused[x],used[x])
    else:
        used[x]=rec(i+1,gcd(x,A[i+1]),1)
        return used[x]


print(rec(-1,-1,0))


Fixed submission:
import fractions

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

L=[0]*(N+1)
R=[0]*(N+1)

def gcd(x,y):
    if x==0 or y==0:
        return max(x,y)
    return fractions.gcd(x,y)

for i in range(N):
    j=N-i

    L[i+1]=gcd(L[i],A[i])
    R[j-1]=gcd(R[j],A[j-1])
ans=0

for i in range(N):
    ans=max(ans,gcd(L[i],R[i+1]))

print(ans)

Buggy python submission (verdict: Runtime Error):
import fractions

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

used={}
unused={}

def gcd(x,y):
    if x==-1 or y==-1:
        return max(x,y)
    return fractions.gcd(x,y)

def rec(i,x,f):
    if i+1==N and f==1:
        return x
    elif i+1==N and f==0:
        return -1
    
    if f==1 and used.get(x,-2)>-2:
        return used[x]
    if f==0 and unused.get(x,-2)>-2:
        return unused[x]
    
    if f==0:
        unused[x]=rec(i+1,gcd(x,A[i+1]),0)
        used[x]=rec(i+1,x,1)
        return max(unused[x],used[x])
    else:
        used[x]=rec(i+1,gcd(x,A[i+1]),1)
        return used[x]


print(rec(-1,-1,0))


Fixed submission:
import fractions

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

L=[0]*(N+1)
R=[0]*(N+1)

def gcd(x,y):
    if x==0 or y==0:
        return max(x,y)
    return fractions.gcd(x,y)

for i in range(N):
    j=N-i

    L[i+1]=gcd(L[i],A[i])
    R[j-1]=gcd(R[j],A[j-1])
ans=0

for i in range(N):
    ans=max(ans,gcd(L[i],R[i+1]))

print(ans)

Buggy python submission (verdict: Runtime Error):
import fractions

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

used={}
unused={}

def gcd(x,y):
    if x==-1 or y==-1:
        return max(x,y)
    return fractions.gcd(x,y)

def rec(i,x,f):
    if i+1==N and f==1:
        return x
    elif i+1==N and f==0:
        return -1
    
    if f==1 and used.get(x,-1)>0:
        return used[x]
    if f==0 and unused.get(x,-1)>0:
        return unused[x]
    
    if f==0:
        unused[x]=rec(i+1,gcd(x,A[i+1]),0)
        used[x]=rec(i+1,x,1)
        return max(unused[x],used[x])
    else:
        used[x]=rec(i+1,gcd(x,A[i+1]),1)
        return used[x]


print(rec(-1,-1,0))


Fixed submission:
import fractions

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

L=[0]*(N+1)
R=[0]*(N+1)

def gcd(x,y):
    if x==0 or y==0:
        return max(x,y)
    return fractions.gcd(x,y)

for i in range(N):
    j=N-i

    L[i+1]=gcd(L[i],A[i])
    R[j-1]=gcd(R[j],A[j-1])
ans=0

for i in range(N):
    ans=max(ans,gcd(L[i],R[i+1]))

print(ans)

Buggy python submission (verdict: Runtime Error):
import math

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

used={}
unused={}

def gcd(x,y):
    if x==-1 or y==-1:
        return max(x,y)
    return math.gcd(x,y)

def rec(i,x,f):
    if i+1==N and f==1:
        return x
    elif i+1==N and f==0:
        return -1
    
    if f==1 and used.get(x,-1)>0:
        return used[x]
    if f==0 and unused.get(x,-1)>0:
        return unused[x]
    
    if f==0:
        unused[x]=rec(i+1,gcd(x,A[i+1]),0)
        used[x]=rec(i+1,x,1)
        return max(unused[x],used[x])
    else:
        used[x]=rec(i+1,gcd(x,A[i+1]),1)
        return used[x]


print(rec(-1,-1,0))


Fixed submission:
import fractions

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

L=[0]*(N+1)
R=[0]*(N+1)

def gcd(x,y):
    if x==0 or y==0:
        return max(x,y)
    return fractions.gcd(x,y)

for i in range(N):
    j=N-i

    L[i+1]=gcd(L[i],A[i])
    R[j-1]=gcd(R[j],A[j-1])
ans=0

for i in range(N):
    ans=max(ans,gcd(L[i],R[i+1]))

print(ans)

Buggy python submission (verdict: Runtime Error):
import math

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

used={}
unused={}

def gcd(x,y):
    if x==-1 or y==-1:
        return max(x,y)
    return math.gcd(x,y)

def rec(i,x,f):
    if i+1==N and f==1:
        return x
    elif i+1==N and f==0:
        return -1
    
    if f==1 and used.get(x,-1)>0:
        return used[x]
    if f==0 and unused.get(x,-1)>0:
        return unused[x]
    
    if f==0:
        unused[x]=rec(i+1,gcd(x,A[i+1]),0)
        used[x]=rec(i+1,x,1)
        return max(unused[x],used[x])
    else:
        used[x]=rec(i+1,gcd(x,A[i+1]),1)
        return used[x]


print(rec(-1,-1,0))


Fixed submission:
import fractions

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

L=[0]*(N+1)
R=[0]*(N+1)

def gcd(x,y):
    if x==0 or y==0:
        return max(x,y)
    return fractions.gcd(x,y)

for i in range(N):
    j=N-i

    L[i+1]=gcd(L[i],A[i])
    R[j-1]=gcd(R[j],A[j-1])
ans=0

for i in range(N):
    ans=max(ans,gcd(L[i],R[i+1]))

print(ans)