n=int(eval(input()))

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

def gcd(a,b):

  while b:a,b=b,a%b

  return a

b=[0]*n

c=[0]*n

b[0]=a[0]

c[-1]=a[-1]

for i in range(1,n):b[i]=gcd(b[i-1],a[i])

for i in range(n-2,-1,-1):c[i]=gcd(c[i+1],a[i])

ans=max(c[1],b[-2])

for i in range(1,n-1):ans=max(ans,gcd(b[i-1],c[i+1]))

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

  while b:a,b=b,a%b

  return a

n=int(eval(input()))

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

if n==2:print((max(a[0],a[1])));exit()

left=[a[0]]

for i in range(1,n):left.append(gcd(left[-1],a[i]))

right=[a[n-1]]

for i in range(n-2,-1,-1):right.append(gcd(right[-1],a[i]))

right.reverse()

ans=max(right[1],left[n-2])

print((max(ans,max(gcd(left[i-1],right[i+1])for i in range(1,n-1)))))
n = int(eval(input()))
a = list(map(int, input().split()))


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


b = [0] * n
c = [0] * n
b[0] = a[0]
c[-1] = a[-1]
for i in range(1, n):
    b[i] = gcd(b[i - 1], a[i])
for i in range(n - 2, -1, -1):
    c[i] = gcd(c[i + 1], a[i])
ans = max(c[1], b[-2])
for i in range(1, n - 1):
    ans = max(ans, gcd(b[i - 1], c[i + 1]))
print(ans)

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


n = int(eval(input()))
a = list(map(int, input().split()))
if n == 2:
    print((max(a[0], a[1])))
    exit()
left = [a[0]]
for i in range(1, n):
    left.append(gcd(left[-1], a[i]))
right = [a[n - 1]]
for i in range(n - 2, -1, -1):
    right.append(gcd(right[-1], a[i]))
right.reverse()
ans = max(right[1], left[n - 2])
print((max(ans, max(gcd(left[i - 1], right[i + 1]) for i in range(1, n - 1)))))

-n = int(eval(input())) -a = list(map(int, input().split())) - - -b = [0] * n -c = [0] * n -b[0] = a[0] -c[-1] = a[-1] +n = int(eval(input())) +a = list(map(int, input().split())) +if n == 2: +    print((max(a[0], a[1]))) +    exit() +left = [a[0]] -    b[i] = gcd(b[i - 1], a[i]) +    left.append(gcd(left[-1], a[i])) +right = [a[n - 1]] -    c[i] = gcd(c[i + 1], a[i]) -ans = max(c[1], b[-2]) -for i in range(1, n - 1): -    ans = max(ans, gcd(b[i - 1], c[i + 1])) -print(ans) +    right.append(gcd(right[-1], a[i])) +right.reverse() +ans = max(right[1], left[n - 2]) +print((max(ans, max(gcd(left[i - 1], right[i + 1]) for i in range(1, n - 1)))))