def gcd(a, b):

    if b == 0:

        return a

    else:

        return gcd(b,a%b)



n = int(eval(input()))

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

r = []

l = []

t = a[0]

for i in a:

    t = gcd(t, i)

    l.append(t)

t = a[-1]

for i in a[::-1]:

    t = gcd(t, i)

    r.append(t)

r = r[::-1]

ans = 0

for i in range(n):

    if i == 0:

        ans = max(ans, r[1])

        continue

    if i == n - 1:

        ans = max(ans, l[-2])

        continue

    ans = max(ans, gcd(l[i-1], r[i+1]))



print(ans)

def gcd(a,b):

    if b==0:

        return a

    else:

        return gcd(b,a%b)

eval(input())

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

gcd_l = [i for i in l]

gcd_r = [i for i in l]

for i in range(1,len(l)):

    gcd_l[i] = gcd(gcd_l[i-1],gcd_l[i])



for i in range(0, len(l)-1)[::-1]:

    gcd_r[i] = gcd(gcd_r[i+1], gcd_r[i])



ans = max(gcd_r[1],gcd_l[-2])

for i in range(1,len(l)-1):

    ans = max(ans,gcd(gcd_l[i-1],gcd_r[i+1]))

print(ans)
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)


n = int(eval(input()))
a = list(map(int, input().split()))
r = []
l = []
t = a[0]
for i in a:
    t = gcd(t, i)
    l.append(t)
t = a[-1]
for i in a[::-1]:
    t = gcd(t, i)
    r.append(t)
r = r[::-1]
ans = 0
for i in range(n):
    if i == 0:
        ans = max(ans, r[1])
        continue
    if i == n - 1:
        ans = max(ans, l[-2])
        continue
    ans = max(ans, gcd(l[i - 1], r[i + 1]))
print(ans)

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)


eval(input())
l = list(map(int, input().split()))
gcd_l = [i for i in l]
gcd_r = [i for i in l]
for i in range(1, len(l)):
    gcd_l[i] = gcd(gcd_l[i - 1], gcd_l[i])
for i in range(0, len(l) - 1)[::-1]:
    gcd_r[i] = gcd(gcd_r[i + 1], gcd_r[i])
ans = max(gcd_r[1], gcd_l[-2])
for i in range(1, len(l) - 1):
    ans = max(ans, gcd(gcd_l[i - 1], gcd_r[i + 1]))
print(ans)

-n = int(eval(input())) -a = list(map(int, input().split())) -r = [] -l = [] -t = a[0] -for i in a: -    t = gcd(t, i) -    l.append(t) -t = a[-1] -for i in a[::-1]: -    t = gcd(t, i) -    r.append(t) -r = r[::-1] -ans = 0 -for i in range(n): -    if i == 0: -        ans = max(ans, r[1]) -        continue -    if i == n - 1: -        ans = max(ans, l[-2]) -        continue -    ans = max(ans, gcd(l[i - 1], r[i + 1])) +eval(input()) +l = list(map(int, input().split())) +gcd_l = [i for i in l] +gcd_r = [i for i in l] +for i in range(1, len(l)): +    gcd_l[i] = gcd(gcd_l[i - 1], gcd_l[i]) +for i in range(0, len(l) - 1)[::-1]: +    gcd_r[i] = gcd(gcd_r[i + 1], gcd_r[i]) +ans = max(gcd_r[1], gcd_l[-2]) +for i in range(1, len(l) - 1): +    ans = max(ans, gcd(gcd_l[i - 1], gcd_r[i + 1]))