from collections import deque

def gcm(a, b):

  if a < b:

    a = a+b

    b=a-b

    a = a-b

  if b == 0:

    return a

  else:

    r = a%b

    return b if r == 0 else gcm(b, r)

N = int(eval(input()))

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

L = deque([0])

for i in range(1, N):

  L.append(gcm(L[-1],A[i-1]))

R = deque([0])

for i in reversed(list(range(N-1))):

  R.appendleft(gcm(R[0],A[i+1]))

ans = 0

for i in range(N):

  ans = max(ans, gcm(L[i],R[i]))

print(ans)

import sys

sys.setrecursionlimit(10**5)

def GCM(a, b):

  if a < b:

    a += b

    b = a-b

    a -= b

  if a % b == 0:

    return b

  else:

    return GCM(b, a%b)



N = int(eval(input()))

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

l2r =[]

r2l = []

g = A[0]

for a in A:

  g = GCM(g, a)

  l2r.append(g)

g = A[-1]

for a in reversed(A):

  g = GCM(g, a)

  r2l.append(g)

r2l = list(reversed(r2l))

ans = r2l[1]

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

  ans = max(ans, GCM(l2r[i-1], r2l[i+1]))

ans = max(ans, l2r[N-2])

print(ans)
from collections import deque


def gcm(a, b):
    if a < b:
        a = a + b
        b = a - b
        a = a - b
    if b == 0:
        return a
    else:
        r = a % b
        return b if r == 0 else gcm(b, r)


N = int(eval(input()))
A = list(map(int, input().split()))
L = deque([0])
for i in range(1, N):
    L.append(gcm(L[-1], A[i - 1]))
R = deque([0])
for i in reversed(list(range(N - 1))):
    R.appendleft(gcm(R[0], A[i + 1]))
ans = 0
for i in range(N):
    ans = max(ans, gcm(L[i], R[i]))
print(ans)

import sys

sys.setrecursionlimit(10**5)


def GCM(a, b):
    if a < b:
        a += b
        b = a - b
        a -= b
    if a % b == 0:
        return b
    else:
        return GCM(b, a % b)


N = int(eval(input()))
A = list(map(int, input().split()))
l2r = []
r2l = []
g = A[0]
for a in A:
    g = GCM(g, a)
    l2r.append(g)
g = A[-1]
for a in reversed(A):
    g = GCM(g, a)
    r2l.append(g)
r2l = list(reversed(r2l))
ans = r2l[1]
for i in range(1, N - 1):
    ans = max(ans, GCM(l2r[i - 1], r2l[i + 1]))
ans = max(ans, l2r[N - 2])
print(ans)

-from collections import deque +import sys + +sys.setrecursionlimit(10**5) -def gcm(a, b): +def GCM(a, b): -        a = a + b +        a += b -        a = a - b -    if b == 0: -        return a +        a -= b +    if a % b == 0: +        return b -        r = a % b -        return b if r == 0 else gcm(b, r) +        return GCM(b, a % b) -L = deque([0]) -for i in range(1, N): -    L.append(gcm(L[-1], A[i - 1])) -R = deque([0]) -for i in reversed(list(range(N - 1))): -    R.appendleft(gcm(R[0], A[i + 1])) -ans = 0 -for i in range(N): -    ans = max(ans, gcm(L[i], R[i])) +l2r = [] +r2l = [] +g = A[0] +for a in A: +    g = GCM(g, a) +    l2r.append(g) +g = A[-1] +for a in reversed(A): +    g = GCM(g, a) +    r2l.append(g) +r2l = list(reversed(r2l)) +ans = r2l[1] +for i in range(1, N - 1): +    ans = max(ans, GCM(l2r[i - 1], r2l[i + 1])) +ans = max(ans, l2r[N - 2])