def gcdf(a,n,a0):
    a.sort()
    a0=a[0]
    a=[int(x%a0) for x in a if x%a0 != 0]
#    print("a2:",a)
    if len(a)==0:
        return a0
    else:
        a.append(a0)
        a0=min(a)
        return gcdf(a,n,a0) 

#n=8
#a=[746130, 1385670, 4849845, 881790, 3233230, 1939938, 570570, 510510]
#ans=[19]
#n=2
#a=[1000000000, 1000000000]
#n=5
#a=[15, 18, 24, 36, 81]
#n=3
#a=[7, 6, 8]
n=int(input())
a=[]
for i in map(int,input().split()):
    a.append(i)

#print(a)
if n==2:
    print(max(a))
elif n<=2**10:
    gcdv=0
    for i in range(n):
        acpy=list(a)
        del acpy[i]
        a0=acpy[0]
        gcdx=gcdf(acpy,n-1,a0)
        if gcdx>gcdv:
            gcdv=gcdx
    print(gcdv)
else:
    a.sort()
    ns=int(n/4)
    a1=a[0:ns]
    a2=a[ns:ns*2]
    a3=a[ns*2:ns*3]
    a4=a[ns*3:n]
#    print(a1)
#    print(a2)
#    print(a3)
#    print(a4)
    gcdv=0
    a10=a1[0]
    a20=a2[0]
    a30=a3[0]
    a40=a4[0]
    gcd1=gcdf(a1,len(a1),a10)
    gcd2=gcdf(a2,len(a2),a20)
    gcd3=gcdf(a3,len(a3),a30)
    gcd4=gcdf(a4,len(a4),a40)
    for i in range(ns):
#        acpy=list(a1)
        acpy=a1.copy()
        acpy.append(gcd2)
        acpy.append(gcd3)
        acpy.append(gcd4)
        del acpy[i]
#        print(i,acpy)
        gcdx=gcdf(acpy,len(acpy),a10)
        if gcdx>gcdv:
            gcdv=gcdx
#    print(gcdv,a1)
    for i in range(ns):
#        acpy=list(a2)
        acpy=a2.copy()
        acpy.append(gcd1)
        acpy.append(gcd3)
        acpy.append(gcd4)
        del acpy[i]
#        print(i,acpy)
        gcdx=gcdf(acpy,len(acpy),a20)
        if gcdx>gcdv:
            gcdv=gcdx
#    print(gcdv,a2)
    for i in range(ns):
#        acpy=list(a3)
        acpy=a3.copy()
        acpy.append(gcd1)
        acpy.append(gcd2)
        acpy.append(gcd4)
        del acpy[i]
#        print(i,acpy)
        gcdx=gcdf(acpy,len(acpy),a30)
        if gcdx>gcdv:
            gcdv=gcdx
#    print(gcdv,a3)
    for i in range(ns):
#        acpy=list(a4)
        acpy=a4.copy()
        acpy.append(gcd1)
        acpy.append(gcd2)
        acpy.append(gcd3)
        del acpy[i]
#        print(i,acpy)
        gcdx=gcdf(acpy,len(acpy),a40)
        if gcdx>gcdv:
            gcdv=gcdx
#    print(gcdv,a4)
    print(gcdv)


### FIXED CODE ###

def gcdf(a):
    a.sort()
#    print("a2:",a)
    a0=a[0]
    a=[int(x%a0) for x in a if x%a0 != 0]
#    print("a2:",a)
    if len(a)==0:
        return a0
    else:
        a.append(a0)
        a0=min(a)
        return gcdf(a) 

#n=8
#a=[746130, 1385670, 4849845, 881790, 3233230, 1939938, 570570, 510510]
#ans=[19]
#n=2
#a=[1000000000, 1000000000]
#n=5
#a=[15, 18, 24, 36, 81]
#n=3
#a=[7, 6, 8]
n=int(input())
a=[]
for i in map(int,input().split()):
    a.append(i)
if n==2:
    print(max(a))
elif n<2**10:
    gcdv=0
    for i in range(n):
        acpy=list(a)
        del acpy[i]
        gcdx=gcdf(acpy)
        if gcdx>gcdv:
            gcdv=gcdx
    print(gcdv)
else:
    m=int(n**(1/2))
    ns=int(n/m)
    rgcd=[]
    for mi in range(m):
        ms=ns*mi
        if mi==m-1:
            am=a[ms:n]
        else:
            am=a[ms:ms+ns]
        gcdm=gcdf(am)
        rgcd.append(gcdm)
    gcdv=0

    for mi in range(m):
        rgcd1=list(rgcd)
        del rgcd1[mi]
        gcdrg1=gcdf(rgcd1)
        ms=ns*mi
        if mi==m-1:
            am=a[ms:n]
        else:
            am=a[ms:ms+ns]
#        print(mi,gcdf(am),len(am),gcdf(rgcd1))
        for i in range(len(am)):
            acpy=list(am)
#            del acpy[i]
#            acpy.append(gcdrg1)
            acpy[i]=gcdrg1
            gcdx=gcdf(acpy)
            if gcdx>gcdv:
                gcdv=gcdx
    print(gcdv)