from fractions import gcd

n = int(eval(input()))

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

mae = [a[0]]

for i in range(n-1):

    mae.append(gcd(mae[i],a[i+1]))

ushiro = [a[n-1]]

for i in range(n-1):

    ushiro.append(gcd(ushiro[i],a[n-i-2]))



ans = ushiro[n-2]



for i in range(n-1):

    if i != n-2:

        ans = max(ans,gcd(mae[i],ushiro[n-i-3]))

    else:

        ans = max(ans,mae[n-2])



print(ans)

from fractions import gcd

n = int(eval(input()))

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



s = [a[0]]

for i in range(1,n):

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



u = [a[n-1]]

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

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



#print(s,u)



ans = max(u[-2],s[-2])

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

    #print(s[i-1],u[-2-i])

    now = gcd(s[i-1],u[-2-i])

    ans = max(ans,now)

print(ans)
from fractions import gcd

n = int(eval(input()))
a = list(map(int, input().split()))
mae = [a[0]]
for i in range(n - 1):
    mae.append(gcd(mae[i], a[i + 1]))
ushiro = [a[n - 1]]
for i in range(n - 1):
    ushiro.append(gcd(ushiro[i], a[n - i - 2]))
ans = ushiro[n - 2]
for i in range(n - 1):
    if i != n - 2:
        ans = max(ans, gcd(mae[i], ushiro[n - i - 3]))
    else:
        ans = max(ans, mae[n - 2])
print(ans)

from fractions import gcd

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

-mae = [a[0]] -for i in range(n - 1): -    mae.append(gcd(mae[i], a[i + 1])) -ushiro = [a[n - 1]] -for i in range(n - 1): -    ushiro.append(gcd(ushiro[i], a[n - i - 2])) -ans = ushiro[n - 2] -for i in range(n - 1): -    if i != n - 2: -        ans = max(ans, gcd(mae[i], ushiro[n - i - 3])) -    else: -        ans = max(ans, mae[n - 2]) +s = [a[0]] +for i in range(1, n): +    s.append(gcd(s[-1], a[i])) +u = [a[n - 1]] +for i in range(n - 2, -1, -1): +    u.append(gcd(u[-1], a[i])) +# print(s,u) +ans = max(u[-2], s[-2]) +for i in range(1, n - 1): +    # print(s[i-1],u[-2-i]) +    now = gcd(s[i - 1], u[-2 - i]) +    ans = max(ans, now)