import sys

sys.setrecursionlimit(10**6)



def Lgcd(i):

    if i == 0:

        return 0

    if i == 1:

        return a_s[0]

    if i in Lmemo:

        return Lmemo[i]

    re = gcd(Lgcd(i - 1), a_s[i - 1])

    Lmemo[i] = re

    return re





def Rgcd(i):

    if i == n - 1:

        return 0

    if i == n - 2:

        return a_s[-1]

    if i in Rmemo:

        return Rmemo[i]

    re = gcd(Rgcd(i + 1), a_s[i + 1])

    Rmemo[i] = re

    return re





def gcd(a, b):

    if a * b == 0:

        return a + b

    while 1:

        a, b = b, a % b

        if b == 0:

            return a





Lmemo = {}

Rmemo = {}

n = int(eval(input()))

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

mx = 0

for i in range(n):

    g = gcd(Lgcd(i),Rgcd(i))

    if g > mx:

        mx = g

print(mx)

import sys



sys.setrecursionlimit(10 ** 6)

int1 = lambda x: int(x) - 1

p2D = lambda x: print(*x, sep="\n")

def MI(): return map(int, sys.stdin.readline().split())

def LI(): return list(map(int, sys.stdin.readline().split()))

def LLI(rows_number): return [LI() for _ in range(rows_number)]

def gcd(a,b):

    while b>0:a,b=b,a%b

    return a



def main():

    n=int(input())

    aa=LI()

    gl=[0]*n

    gr=[0]*n

    g=aa[0]

    for i,a in enumerate(aa):

        g=gcd(g,a)

        gl[i]=g

    g=aa[-1]

    for i,a in enumerate(aa[::-1]):

        g=gcd(g,a)

        gr[n-1-i]=g

    ans=max(gl[n-2],gr[1])

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

        g=gcd(gl[i-1],gr[i+1])

        if g>ans:ans=g

    print(ans)



main()

import sys

sys.setrecursionlimit(10**6)


def Lgcd(i):
    if i == 0:
        return 0
    if i == 1:
        return a_s[0]
    if i in Lmemo:
        return Lmemo[i]
    re = gcd(Lgcd(i - 1), a_s[i - 1])
    Lmemo[i] = re
    return re


def Rgcd(i):
    if i == n - 1:
        return 0
    if i == n - 2:
        return a_s[-1]
    if i in Rmemo:
        return Rmemo[i]
    re = gcd(Rgcd(i + 1), a_s[i + 1])
    Rmemo[i] = re
    return re


def gcd(a, b):
    if a * b == 0:
        return a + b
    while 1:
        a, b = b, a % b
        if b == 0:
            return a


Lmemo = {}
Rmemo = {}
n = int(eval(input()))
a_s = list(map(int, input().split()))
mx = 0
for i in range(n):
    g = gcd(Lgcd(i), Rgcd(i))
    if g > mx:
        mx = g
print(mx)

import sys

sys.setrecursionlimit(10**6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")


def MI():
    return map(int, sys.stdin.readline().split())


def LI():
    return list(map(int, sys.stdin.readline().split()))


def LLI(rows_number):
    return [LI() for _ in range(rows_number)]


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


def main():
    n = int(input())
    aa = LI()
    gl = [0] * n
    gr = [0] * n
    g = aa[0]
    for i, a in enumerate(aa):
        g = gcd(g, a)
        gl[i] = g
    g = aa[-1]
    for i, a in enumerate(aa[::-1]):
        g = gcd(g, a)
        gr[n - 1 - i] = g
    ans = max(gl[n - 2], gr[1])
    for i in range(1, n - 1):
        g = gcd(gl[i - 1], gr[i + 1])
        if g > ans:
            ans = g
    print(ans)


main()

+int1 = lambda x: int(x) - 1 +p2D = lambda x: print(*x, sep="\n") -def Lgcd(i): -    if i == 0: -        return 0 -    if i == 1: -        return a_s[0] -    if i in Lmemo: -        return Lmemo[i] -    re = gcd(Lgcd(i - 1), a_s[i - 1]) -    Lmemo[i] = re -    return re +def MI(): +    return map(int, sys.stdin.readline().split()) -def Rgcd(i): -    if i == n - 1: -        return 0 -    if i == n - 2: -        return a_s[-1] -    if i in Rmemo: -        return Rmemo[i] -    re = gcd(Rgcd(i + 1), a_s[i + 1]) -    Rmemo[i] = re -    return re +def LI(): +    return list(map(int, sys.stdin.readline().split())) + + +def LLI(rows_number): +    return [LI() for _ in range(rows_number)] -    if a * b == 0: -        return a + b -    while 1: +    while b > 0: -        if b == 0: -            return a +    return a -Lmemo = {} -Rmemo = {} -n = int(eval(input())) -a_s = list(map(int, input().split())) -mx = 0 -for i in range(n): -    g = gcd(Lgcd(i), Rgcd(i)) -    if g > mx: -        mx = g -print(mx) +def main(): +    n = int(input()) +    aa = LI() +    gl = [0] * n +    gr = [0] * n +    g = aa[0] +    for i, a in enumerate(aa): +        g = gcd(g, a) +        gl[i] = g +    g = aa[-1] +    for i, a in enumerate(aa[::-1]): +        g = gcd(g, a) +        gr[n - 1 - i] = g +    ans = max(gl[n - 2], gr[1]) +    for i in range(1, n - 1): +        g = gcd(gl[i - 1], gr[i + 1]) +        if g > ans: +            ans = g +    print(ans) + + +main()