from fractions import gcd

n = int(eval(input()))

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

GCD= a[0]

dp = [set() for i in range(n)]

dp[1].add(a[0])

dp[1].add(a[1])

for i in range(1,n):

    x = a[i]

    for j in dp[i-1]:

            dp[i].add(gcd(j,x))

    if x % GCD != 0:

        dp[i].add(GCD)

        GCD = gcd(GCD,x)

print((max(dp[n-1])))
from fractions import gcd

n = int(eval(input()))

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

left = []

right = []



left.append(a[0])

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

    left.append(gcd(left[-1],a[i]))

a = a[::-1]

right.append(a[0])

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

    right.append(gcd(right[-1],a[i]))

ans = 1

for i in range(n-1):

    ans = max(ans,gcd(left[i],right[n-i-3]))

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

print(ans)

from fractions import gcd

n = int(eval(input()))
a = list(map(int, input().split()))
GCD = a[0]
dp = [set() for i in range(n)]
dp[1].add(a[0])
dp[1].add(a[1])
for i in range(1, n):
    x = a[i]
    for j in dp[i - 1]:
        dp[i].add(gcd(j, x))
    if x % GCD != 0:
        dp[i].add(GCD)
        GCD = gcd(GCD, x)
print((max(dp[n - 1])))

from fractions import gcd

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

-GCD = a[0] -dp = [set() for i in range(n)] -dp[1].add(a[0]) -dp[1].add(a[1]) -for i in range(1, n): -    x = a[i] -    for j in dp[i - 1]: -        dp[i].add(gcd(j, x)) -    if x % GCD != 0: -        dp[i].add(GCD) -        GCD = gcd(GCD, x) -print((max(dp[n - 1]))) +left = [] +right = [] +left.append(a[0]) +for i in range(1, n - 1): +    left.append(gcd(left[-1], a[i])) +a = a[::-1] +right.append(a[0]) +for i in range(1, n - 1): +    right.append(gcd(right[-1], a[i])) +ans = 1 +for i in range(n - 1): +    ans = max(ans, gcd(left[i], right[n - i - 3])) +ans = max(ans, left[n - 2], right[n - 2]) +print(ans)