def gcd(a, b):

    (x, lastx) = (0, 1)

    (y, lasty) = (1, 0)

    while b != 0:

        q = a // b

        (a, b) = (b, a % b)

        (x, lastx) = (lastx - q * x, x)

        (y, lasty) = (lasty - q * y, y)

    return a



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])

    ans=max(tmp,ans)



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])

    ans=max(tmp,ans)



print(ans)
def gcd(a, b):
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return a


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])
    ans = max(tmp, ans)
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])
    ans = max(tmp, ans)
print(ans)

-def gcd(a, b): -    (x, lastx) = (0, 1) -    (y, lasty) = (1, 0) -    while b != 0: -        q = a // b -        (a, b) = (b, a % b) -        (x, lastx) = (lastx - q * x, x) -        (y, lasty) = (lasty - q * y, y) -    return a +def gcd(x, y): +    if y > x: +        x, y = y, x +    while y: +        x, y = y, x % y +    return x