def gcd(x, y):

    if y > x:

        x, y = y, x

    while y:

        x, y = y, x % y

    return x



N=int(eval(input()))

a=list(map(int,input().split()))



l=[0]*N

l[0]=a[0]

for i in range(1,N):

    l[i]=gcd(l[i-1],a[i])



r=[0]*N

r[N-1]=a[N-1]

for i in range(N-2,-1,-1):

    r[i]=gcd(r[i+1],a[i])



ans=max(r[1],l[N-2])

for i in range(1,N-1):

    tmp=gcd(l[i-1],r[i+1])

    if tmp>ans: ans=tmp



print(ans)
def gcd(a,b):

    if b>a:

        a,b=b,a

    while b:

        a,b=b, a%b

    return a





def cul(n,x):

    l=len(x)

    b=[x[i] for i in range(l)]

    b.pop(n)

    tmp=b[0]

    for i in range(1,l-1):

        tmp=gcd(tmp,b[i])

    return tmp



import sys

import math

p=100

N=int(eval(input()))

a=list(map(int,input().split()))

if N<=p:

    ans=0

    

    for i in range(N):

        tmp=cul(i,a)        

        if tmp>ans: ans=tmp

    print(ans)

    sys.exit()

        

M=a[0]

for i in range(1,p):

    M=gcd(M,a[i])



ans=0





R=a[p]

for i in range(p,N):

    r=gcd(R,a[i])



if r>ans:

    for i in range(p):

        s=gcd(cul(i,a[:p]),R)

        if s>ans: ans=s



print(ans)

def gcd(x, y):
    if y > x:
        x, y = y, x
    while y:
        x, y = y, x % y
    return x


N = int(eval(input()))
a = list(map(int, input().split()))
l = [0] * N
l[0] = a[0]
for i in range(1, N):
    l[i] = gcd(l[i - 1], a[i])
r = [0] * N
r[N - 1] = a[N - 1]
for i in range(N - 2, -1, -1):
    r[i] = gcd(r[i + 1], a[i])
ans = max(r[1], l[N - 2])
for i in range(1, N - 1):
    tmp = gcd(l[i - 1], r[i + 1])
    if tmp > ans:
        ans = tmp
print(ans)

def gcd(a, b):
    if b > a:
        a, b = b, a
    while b:
        a, b = b, a % b
    return a


def cul(n, x):
    l = len(x)
    b = [x[i] for i in range(l)]
    b.pop(n)
    tmp = b[0]
    for i in range(1, l - 1):
        tmp = gcd(tmp, b[i])
    return tmp


import sys
import math

p = 100
N = int(eval(input()))
a = list(map(int, input().split()))
if N <= p:
    ans = 0
    for i in range(N):
        tmp = cul(i, a)
        if tmp > ans:
            ans = tmp
    print(ans)
    sys.exit()
M = a[0]
for i in range(1, p):
    M = gcd(M, a[i])
ans = 0
R = a[p]
for i in range(p, N):
    r = gcd(R, a[i])
if r > ans:
    for i in range(p):
        s = gcd(cul(i, a[:p]), R)
        if s > ans:
            ans = s
print(ans)

-def gcd(x, y): -    if y > x: -        x, y = y, x -    while y: -        x, y = y, x % y -    return x +def gcd(a, b): +    if b > a: +        a, b = b, a +    while b: +        a, b = b, a % b +    return a +def cul(n, x): +    l = len(x) +    b = [x[i] for i in range(l)] +    b.pop(n) +    tmp = b[0] +    for i in range(1, l - 1): +        tmp = gcd(tmp, b[i]) +    return tmp + + +import sys +import math + +p = 100 -l = [0] * N -l[0] = a[0] -for i in range(1, N): -    l[i] = gcd(l[i - 1], a[i]) -r = [0] * N -r[N - 1] = a[N - 1] -for i in range(N - 2, -1, -1): -    r[i] = gcd(r[i + 1], a[i]) -ans = max(r[1], l[N - 2]) -for i in range(1, N - 1): -    tmp = gcd(l[i - 1], r[i + 1]) -    if tmp > ans: -        ans = tmp +if N <= p: +    ans = 0 +    for i in range(N): +        tmp = cul(i, a) +        if tmp > ans: +            ans = tmp +    print(ans) +    sys.exit() +M = a[0] +for i in range(1, p): +    M = gcd(M, a[i]) +ans = 0 +R = a[p] +for i in range(p, N): +    r = gcd(R, a[i]) +if r > ans: +    for i in range(p): +        s = gcd(cul(i, a[:p]), R) +        if s > ans: +            ans = s