def gcd(a,b):

    if b==0:

        return a

    return gcd(b,a%b)

N=int(eval(input()))

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



L=[0,0]#why

for ai in A:

    L.append(gcd(L[-1],ai))

    #print(L)



R=[0,0]#why

for ai in A[::-1]:

    R.append(gcd(R[-1],ai))

    #print(R)

#下のやつの解明

max=0

for l,r in zip(L,reversed(R)):

    if(gcd(l,r)>max):

        max=gcd(l,r)



print(max)
#coding:utf-8

import fractions



def main():

    N=int(eval(input()))

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

    gcd=0

    gcd_list_front=[]

    gcd_list_back=[]

    gcd_list_front.append(num[0])

    gcd_list_back.append(num[-1])



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

        gcd_list_front.append(fractions.gcd(gcd_list_front[i-1],num[i]))

        gcd_list_back.append(fractions.gcd(gcd_list_back[i-1],num[-i-1]))

    gcd_list_back.reverse()



    gcd=max(gcd_list_back[0],gcd_list_front[-1])

    for i in range(0,N-2):

       temp_gcd=fractions.gcd(gcd_list_front[i],gcd_list_back[i+1])

       if temp_gcd>gcd:

           gcd=temp_gcd

    print(gcd)





if  __name__=="__main__":

    main()

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


N = int(eval(input()))
A = list(map(int, input().split()))
L = [0, 0]  # why
for ai in A:
    L.append(gcd(L[-1], ai))
    # print(L)
R = [0, 0]  # why
for ai in A[::-1]:
    R.append(gcd(R[-1], ai))
    # print(R)
# 下のやつの解明
max = 0
for l, r in zip(L, reversed(R)):
    if gcd(l, r) > max:
        max = gcd(l, r)
print(max)

# coding:utf-8
import fractions


def main():
    N = int(eval(input()))
    num = list(map(int, input().split()))
    gcd = 0
    gcd_list_front = []
    gcd_list_back = []
    gcd_list_front.append(num[0])
    gcd_list_back.append(num[-1])
    for i in range(1, N - 1):
        gcd_list_front.append(fractions.gcd(gcd_list_front[i - 1], num[i]))
        gcd_list_back.append(fractions.gcd(gcd_list_back[i - 1], num[-i - 1]))
    gcd_list_back.reverse()
    gcd = max(gcd_list_back[0], gcd_list_front[-1])
    for i in range(0, N - 2):
        temp_gcd = fractions.gcd(gcd_list_front[i], gcd_list_back[i + 1])
        if temp_gcd > gcd:
            gcd = temp_gcd
    print(gcd)


if __name__ == "__main__":
    main()

-def gcd(a, b): -    if b == 0: -        return a -    return gcd(b, a % b) +# coding:utf-8 +import fractions -N = int(eval(input())) -A = list(map(int, input().split())) -L = [0, 0]  # why -for ai in A: -    L.append(gcd(L[-1], ai)) -    # print(L) -R = [0, 0]  # why -for ai in A[::-1]: -    R.append(gcd(R[-1], ai)) -    # print(R) -# 下のやつの解明 -max = 0 -for l, r in zip(L, reversed(R)): -    if gcd(l, r) > max: -        max = gcd(l, r) -print(max) +def main(): +    N = int(eval(input())) +    num = list(map(int, input().split())) +    gcd = 0 +    gcd_list_front = [] +    gcd_list_back = [] +    gcd_list_front.append(num[0]) +    gcd_list_back.append(num[-1]) +    for i in range(1, N - 1): +        gcd_list_front.append(fractions.gcd(gcd_list_front[i - 1], num[i])) +        gcd_list_back.append(fractions.gcd(gcd_list_back[i - 1], num[-i - 1])) +    gcd_list_back.reverse() +    gcd = max(gcd_list_back[0], gcd_list_front[-1]) +    for i in range(0, N - 2): +        temp_gcd = fractions.gcd(gcd_list_front[i], gcd_list_back[i + 1]) +        if temp_gcd > gcd: +            gcd = temp_gcd +    print(gcd) + + +if __name__ == "__main__": +    main()