Buggy python submission (verdict: Runtime Error):
import math
N = int(input())
A = [int(i) for i in input().split()]

'''
'init(a)': 配列aで初期化。O(N)
'update(k,x)': a[k]をxに変更 O(logN)
'query(p,q)': [p,q)について "segfunc" したものを返す O(logN)
'ide_ele' : 単位元。
'''


def segfunc(x, y):
    return math.gcd(x, y)


def init(init_val):
    # set_val
    for i in range(N):
        seg[i+num-1] = init_val[i]
    # built
    for i in range(num-2, -1, -1):
        seg[i] = segfunc(seg[2*i+1], seg[2*i+2])


def update(k, x):
    k += num-1
    seg[k] = x
    while k:
        k = (k-1)//2
        seg[k] = segfunc(seg[k*2+1], seg[k*2+2])


def query(p, q):
    if q <= p:
        return ide_ele
    p += num-1
    q += num-2
    res = ide_ele
    while q-p > 1:
        if p & 1 == 0:
            res = segfunc(res, seg[p])
        if q & 1 == 1:
            res = segfunc(res, seg[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = segfunc(res, seg[p])
    else:
        res = segfunc(segfunc(res, seg[p]), seg[q])
    return res


#####単位元######
ide_ele = A[-1]

# num:n以上の最小の2のべき乗
num = 2**(N-1).bit_length()
seg = [ide_ele]*2*num

init(A)

# print(query(0, 2))

ans = 1
for i in range(N):
    ans = max(ans, math.gcd(query(0, i), query(i+1, N)))
print(ans)


Fixed submission:
import sys

sys.setrecursionlimit(1000000)

import fractions
from functools import reduce

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

def mygcd(a,b):
    if a==0:
        return b
    elif b==0:
        return a
    else:
        return fractions.gcd(a,b)

L=[0]*N
for i in range(1,N):
    L[i]=mygcd(L[i-1],A[i-1])

R=[0]*N
for i in range(N-2,-1,-1):
    R[i]=mygcd(R[i+1],A[i+1])

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

print(ans)

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

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


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


ans = 0
for i in range(N):
    B = A[:i]+A[i+1:]
    ans = max(ans, gcd(*B))
print(ans)


Fixed submission:
import sys

sys.setrecursionlimit(1000000)

import fractions
from functools import reduce

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

def mygcd(a,b):
    if a==0:
        return b
    elif b==0:
        return a
    else:
        return fractions.gcd(a,b)

L=[0]*N
for i in range(1,N):
    L[i]=mygcd(L[i-1],A[i-1])

R=[0]*N
for i in range(N-2,-1,-1):
    R[i]=mygcd(R[i+1],A[i+1])

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

print(ans)

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

sys.setrecursionlimit(1000000)

import fractions
from functools import reduce

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

def mygcd(a,b):
    if a==0:
        return b
    elif b==0:
        return a
    else:
        return fractions.gcd(a,b)

L=[0]*N
for i in range(1,N):
    L[i]=mygcd(L[i-1],A[i-1])

R=[0]*N
for i in range(N-2,-1,-1):
    R[i]=mygcd(R[i+1],A[i+1])

ans=1
for i in range(N):
    c=mygcd(L(i),R(i))
    ans=max(ans,c)

print(ans)


Fixed submission:
import sys

sys.setrecursionlimit(1000000)

import fractions
from functools import reduce

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

def mygcd(a,b):
    if a==0:
        return b
    elif b==0:
        return a
    else:
        return fractions.gcd(a,b)

L=[0]*N
for i in range(1,N):
    L[i]=mygcd(L[i-1],A[i-1])

R=[0]*N
for i in range(N-2,-1,-1):
    R[i]=mygcd(R[i+1],A[i+1])

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

print(ans)

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

sys.setrecursionlimit(1000000)

import fractions
from functools import reduce

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

def mygcd(a,b):
    if a==0:
        return b
    elif b==0:
        return a
    else:
        return fractions.gcd(a,b)


def L(n):
    if n==-1:
        return 0
    else:
        return mygcd(L(n-1),A[n])

def R(n):
    if n==N:
        return 0
    else:
        return mygcd(R(n+1),A[n])

ans=1
for i in range(N):
    c=mygcd(L(i-1),R(i+1))
    ans=max(ans,c)

print(ans)

Fixed submission:
import sys

sys.setrecursionlimit(1000000)

import fractions
from functools import reduce

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

def mygcd(a,b):
    if a==0:
        return b
    elif b==0:
        return a
    else:
        return fractions.gcd(a,b)

L=[0]*N
for i in range(1,N):
    L[i]=mygcd(L[i-1],A[i-1])

R=[0]*N
for i in range(N-2,-1,-1):
    R[i]=mygcd(R[i+1],A[i+1])

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

print(ans)

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

sys.setrecursionlimit(1000000)

import fractions
from functools import reduce

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

def mygcd(a,b):
    if a==0:
        return b
    elif b==0:
        return a
    else:
        return fractions.gcd(a,b)


def L(n):
    if n==-1:
        return 0
    else:
        return mygcd(L(n-1),A[n])

def R(n):
    if n==N:
        return 0
    else:
        return mygcd(R(n+1),A[n])

ans=1
for i in range(N):
    c=mygcd(L(i-1),R(i+1))
    ans=max(ans,c)

print(ans)

Fixed submission:
import sys

sys.setrecursionlimit(1000000)

import fractions
from functools import reduce

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

def mygcd(a,b):
    if a==0:
        return b
    elif b==0:
        return a
    else:
        return fractions.gcd(a,b)

L=[0]*N
for i in range(1,N):
    L[i]=mygcd(L[i-1],A[i-1])

R=[0]*N
for i in range(N-2,-1,-1):
    R[i]=mygcd(R[i+1],A[i+1])

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

print(ans)

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

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

def mygcd(a,b):
    if a==0:
        return b
    elif b==0:
        return a
    else:
        return fractions.gcd(a,b)


def L(n):
    if n==-1:
        return 0
    else:
        return mygcd(L(n-1),A[n])

def R(n):
    if n==N:
        return 0
    else:
        return mygcd(R(n+1),A[n])

ans=1
for i in range(N):
    c=mygcd(L(i-1),R(i+1))
    ans=max(ans,c)

print(ans)

Fixed submission:
import sys

sys.setrecursionlimit(1000000)

import fractions
from functools import reduce

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

def mygcd(a,b):
    if a==0:
        return b
    elif b==0:
        return a
    else:
        return fractions.gcd(a,b)

L=[0]*N
for i in range(1,N):
    L[i]=mygcd(L[i-1],A[i-1])

R=[0]*N
for i in range(N-2,-1,-1):
    R[i]=mygcd(R[i+1],A[i+1])

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

print(ans)

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

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

ans=1
for i in range(N):
    b=A[:i]+A[i+1:]
    c=reduce(fractions.gcd, b)
    ans=max(ans,c)

print(ans)

Fixed submission:
import sys

sys.setrecursionlimit(1000000)

import fractions
from functools import reduce

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

def mygcd(a,b):
    if a==0:
        return b
    elif b==0:
        return a
    else:
        return fractions.gcd(a,b)

L=[0]*N
for i in range(1,N):
    L[i]=mygcd(L[i-1],A[i-1])

R=[0]*N
for i in range(N-2,-1,-1):
    R[i]=mygcd(R[i+1],A[i+1])

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

print(ans)

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

import sys
sys.setrecursionlimit(100000000) 

def l(i):
    if i==0:
        return 0
    else:
        return fractions.gcd(l(i-1),A[i-1])

def r(i):
    if i==N:
        return 0
    else:
        return fractions.gcd(r(i+1),A[i])

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

ans=[]
if N==2:
    ans.append(max(A))
else:
    for i in range(N):
        ans.append(fractions.gcd(l(i),r(i+1)))

print(max(ans))

Fixed submission:
import sys

sys.setrecursionlimit(1000000)

import fractions
from functools import reduce

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

def mygcd(a,b):
    if a==0:
        return b
    elif b==0:
        return a
    else:
        return fractions.gcd(a,b)

L=[0]*N
for i in range(1,N):
    L[i]=mygcd(L[i-1],A[i-1])

R=[0]*N
for i in range(N-2,-1,-1):
    R[i]=mygcd(R[i+1],A[i+1])

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

print(ans)

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

import sys
sys.setrecursionlimit(100000000) 

def l(i):
    if i==0:
        return 0
    else:
        return fractions.gcd(l(i-1),A[i-1])

def r(i):
    if i==N:
        return 0
    else:
        return fractions.gcd(r(i+1),A[i])

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

ans=[]
if N==2:
    ans.append(max(A))
else:
    for i in range(N):
        ans.append(fractions.gcd(l(i),r(i+1)))

print(max(ans))

Fixed submission:
import sys

sys.setrecursionlimit(1000000)

import fractions
from functools import reduce

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

def mygcd(a,b):
    if a==0:
        return b
    elif b==0:
        return a
    else:
        return fractions.gcd(a,b)

L=[0]*N
for i in range(1,N):
    L[i]=mygcd(L[i-1],A[i-1])

R=[0]*N
for i in range(N-2,-1,-1):
    R[i]=mygcd(R[i+1],A[i+1])

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

print(ans)

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

def l(i):
    if i==0:
        return 0
    else:
        return fractions.gcd(l(i-1),A[i-1])

def r(i):
    if i==N:
        return 0
    else:
        return fractions.gcd(r(i+1),A[i])

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

ans=[]
if N==2:
    ans.append(max(A))
else:
    for i in range(N):
        ans.append(fractions.gcd(l(i),r(i+1)))

print(max(ans))

Fixed submission:
import sys

sys.setrecursionlimit(1000000)

import fractions
from functools import reduce

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

def mygcd(a,b):
    if a==0:
        return b
    elif b==0:
        return a
    else:
        return fractions.gcd(a,b)

L=[0]*N
for i in range(1,N):
    L[i]=mygcd(L[i-1],A[i-1])

R=[0]*N
for i in range(N-2,-1,-1):
    R[i]=mygcd(R[i+1],A[i+1])

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

print(ans)

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

def l(i):
    if i==0:
        return 0
    else:
        return fractions.gcd(l(i-1),A[i-1])

def r(i):
    if i==N:
        return 0
    else:
        return fractions.gcd(r(i+1),A[i])

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

ans=[]
if N==2:
    ans.append(max(A))
else:
    for i in range(N):
        ans.append(fractions.gcd(l(i),r(i+1)))

print(max(ans))

Fixed submission:
import sys

sys.setrecursionlimit(1000000)

import fractions
from functools import reduce

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

def mygcd(a,b):
    if a==0:
        return b
    elif b==0:
        return a
    else:
        return fractions.gcd(a,b)

L=[0]*N
for i in range(1,N):
    L[i]=mygcd(L[i-1],A[i-1])

R=[0]*N
for i in range(N-2,-1,-1):
    R[i]=mygcd(R[i+1],A[i+1])

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

print(ans)

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

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

ans=1
if N==1:
    ans=10**9
elif N==2:
    ans=max(A)
else:
    for a in A:
        A2=copy.deepcopy(A)
        A2.remove(a)
        ans=max(ans,reduce(fractions.gcd, A2))
print(ans)

Fixed submission:
import sys

sys.setrecursionlimit(1000000)

import fractions
from functools import reduce

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

def mygcd(a,b):
    if a==0:
        return b
    elif b==0:
        return a
    else:
        return fractions.gcd(a,b)

L=[0]*N
for i in range(1,N):
    L[i]=mygcd(L[i-1],A[i-1])

R=[0]*N
for i in range(N-2,-1,-1):
    R[i]=mygcd(R[i+1],A[i+1])

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

print(ans)

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

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

ans=1
if N==1:
    ans=10**9
elif N==2:
    ans=max(A)
else:
    for a in A:
        A2=copy.deepcopy(A)
        A2.remove(a)
        ans=max(ans,reduce(fractions.gcd, A2))
print(ans)

Fixed submission:
import sys

sys.setrecursionlimit(1000000)

import fractions
from functools import reduce

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

def mygcd(a,b):
    if a==0:
        return b
    elif b==0:
        return a
    else:
        return fractions.gcd(a,b)

L=[0]*N
for i in range(1,N):
    L[i]=mygcd(L[i-1],A[i-1])

R=[0]*N
for i in range(N-2,-1,-1):
    R[i]=mygcd(R[i+1],A[i+1])

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

print(ans)

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

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

ans=1
if N==1:
    ans=10**9
elif N==2:
    ans=max(A)
else:
    for a in A:
        A2=copy.deepcopy(A)
        A2.remove(a)
        ans=max(ans,fractions.gcd(*A2))

print(ans)

Fixed submission:
import sys

sys.setrecursionlimit(1000000)

import fractions
from functools import reduce

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

def mygcd(a,b):
    if a==0:
        return b
    elif b==0:
        return a
    else:
        return fractions.gcd(a,b)

L=[0]*N
for i in range(1,N):
    L[i]=mygcd(L[i-1],A[i-1])

R=[0]*N
for i in range(N-2,-1,-1):
    R[i]=mygcd(R[i+1],A[i+1])

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

print(ans)

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

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

ans=1
if len(A)==1:
    ans=10**9
elif len(A)==2:
    ans=max(A)
else:  
    for a in A:
        A2=A-{a}
        ans=max(ans,fractions.gcd(*A2))

print(ans)

Fixed submission:
import sys

sys.setrecursionlimit(1000000)

import fractions
from functools import reduce

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

def mygcd(a,b):
    if a==0:
        return b
    elif b==0:
        return a
    else:
        return fractions.gcd(a,b)

L=[0]*N
for i in range(1,N):
    L[i]=mygcd(L[i-1],A[i-1])

R=[0]*N
for i in range(N-2,-1,-1):
    R[i]=mygcd(R[i+1],A[i+1])

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

print(ans)

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

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

ans=1
if len(A)==1:
    ans=10**9
elif len(A)==2:
    ans=max(A)
else:  
    for a in A:
        A2=A-{a}
        print(A)
        ans=max(ans,fractions.gcd(*A2))

print(ans)

Fixed submission:
import sys

sys.setrecursionlimit(1000000)

import fractions
from functools import reduce

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

def mygcd(a,b):
    if a==0:
        return b
    elif b==0:
        return a
    else:
        return fractions.gcd(a,b)

L=[0]*N
for i in range(1,N):
    L[i]=mygcd(L[i-1],A[i-1])

R=[0]*N
for i in range(N-2,-1,-1):
    R[i]=mygcd(R[i+1],A[i+1])

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

print(ans)

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

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

ans=1
if len(A)==1:
    print(10**9)
elif len(A)==2:
    ans=max(A)
else:  
    for a in A:
        A2=A-{a}
        print(A)
        ans=max(ans,fractions.gcd(*A2))

print(ans)

Fixed submission:
import sys

sys.setrecursionlimit(1000000)

import fractions
from functools import reduce

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

def mygcd(a,b):
    if a==0:
        return b
    elif b==0:
        return a
    else:
        return fractions.gcd(a,b)

L=[0]*N
for i in range(1,N):
    L[i]=mygcd(L[i-1],A[i-1])

R=[0]*N
for i in range(N-2,-1,-1):
    R[i]=mygcd(R[i+1],A[i+1])

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

print(ans)

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

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

ans=1
if len(A)<=2:
    ans=max(A)
else:  
    for a in A:
        A2=A-{a}
        ans=max(ans,fractions.gcd(*A2))

print(ans)

Fixed submission:
import sys

sys.setrecursionlimit(1000000)

import fractions
from functools import reduce

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

def mygcd(a,b):
    if a==0:
        return b
    elif b==0:
        return a
    else:
        return fractions.gcd(a,b)

L=[0]*N
for i in range(1,N):
    L[i]=mygcd(L[i-1],A[i-1])

R=[0]*N
for i in range(N-2,-1,-1):
    R[i]=mygcd(R[i+1],A[i+1])

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

print(ans)

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

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

ans=1
for a in A:
    A2=A-{a}
    ans=max(ans,fractions.gcd(*A2))

print(ans)

Fixed submission:
import sys

sys.setrecursionlimit(1000000)

import fractions
from functools import reduce

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

def mygcd(a,b):
    if a==0:
        return b
    elif b==0:
        return a
    else:
        return fractions.gcd(a,b)

L=[0]*N
for i in range(1,N):
    L[i]=mygcd(L[i-1],A[i-1])

R=[0]*N
for i in range(N-2,-1,-1):
    R[i]=mygcd(R[i+1],A[i+1])

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

print(ans)