n = int(eval(input()))

alist = [int(i) for i in input().split()]

alist.sort()



def calc_gcm(x, y):

    while y != 0:

        z = x % y

        x = y

        y = z

    return x





def get_custum(xlist):

    prev = None

    gcm_list = []

    for a in xlist:

        if prev is None:

            gcm_list.append(a)

            prev = a

            continue

        ret = calc_gcm(a, prev)

        gcm_list.append(ret)

        prev = ret



    for boundary, gcm in enumerate(gcm_list):

        if gcm == gcm_list[-1]:

            break



    gcm_1 = None

    for i, a in enumerate(xlist):

        if i == boundary - 1:

            continue

        if gcm_1 is None:

            gcm_1 = a

            continue

        gcm_1 = calc_gcm(a, gcm_1)



    gcm_2 = None

    for i, a in enumerate(xlist):

        if i == boundary:

            continue

        if gcm_2 is None:

            gcm_2 = a

            continue

        gcm_2 = calc_gcm(a, gcm_2)



    return max(gcm_1, gcm_2)



ret1 = get_custum(alist)

alist.reverse()

ret2 = get_custum(alist)



print((max(ret1, ret2)))

n = int(eval(input()))

alist = [int(i) for i in input().split()]



def calc_gcm(x, y):

    while y != 0:

        z = x % y

        x = y

        y = z

    return x





def listup_gcm(xlist):

    list_gcm = []

    prev = None

    for a in xlist:

        if prev is None:

            list_gcm.append(a)

            prev = a

            continue

        gcm = calc_gcm(prev, a)

        list_gcm.append(gcm)

        prev = gcm

    return list_gcm





left_gcm = listup_gcm(alist)

alist.reverse()

right_gcm = listup_gcm(alist)

right_gcm.reverse()





maxgcm = 0

for i in range(n):

    if i == 0:

        maxgcm = max(maxgcm, right_gcm[1])

    elif i == n - 1:

        maxgcm = max(maxgcm, left_gcm[n-2])

    else:

        maxgcm = max(maxgcm, calc_gcm(left_gcm[i-1], right_gcm[i+1]))



print(maxgcm)

n = int(eval(input()))
alist = [int(i) for i in input().split()]
alist.sort()


def calc_gcm(x, y):
    while y != 0:
        z = x % y
        x = y
        y = z
    return x


def get_custum(xlist):
    prev = None
    gcm_list = []
    for a in xlist:
        if prev is None:
            gcm_list.append(a)
            prev = a
            continue
        ret = calc_gcm(a, prev)
        gcm_list.append(ret)
        prev = ret
    for boundary, gcm in enumerate(gcm_list):
        if gcm == gcm_list[-1]:
            break
    gcm_1 = None
    for i, a in enumerate(xlist):
        if i == boundary - 1:
            continue
        if gcm_1 is None:
            gcm_1 = a
            continue
        gcm_1 = calc_gcm(a, gcm_1)
    gcm_2 = None
    for i, a in enumerate(xlist):
        if i == boundary:
            continue
        if gcm_2 is None:
            gcm_2 = a
            continue
        gcm_2 = calc_gcm(a, gcm_2)
    return max(gcm_1, gcm_2)


ret1 = get_custum(alist)
alist.reverse()
ret2 = get_custum(alist)
print((max(ret1, ret2)))

n = int(eval(input()))
alist = [int(i) for i in input().split()]


def calc_gcm(x, y):
    while y != 0:
        z = x % y
        x = y
        y = z
    return x


def listup_gcm(xlist):
    list_gcm = []
    prev = None
    for a in xlist:
        if prev is None:
            list_gcm.append(a)
            prev = a
            continue
        gcm = calc_gcm(prev, a)
        list_gcm.append(gcm)
        prev = gcm
    return list_gcm


left_gcm = listup_gcm(alist)
alist.reverse()
right_gcm = listup_gcm(alist)
right_gcm.reverse()
maxgcm = 0
for i in range(n):
    if i == 0:
        maxgcm = max(maxgcm, right_gcm[1])
    elif i == n - 1:
        maxgcm = max(maxgcm, left_gcm[n - 2])
    else:
        maxgcm = max(maxgcm, calc_gcm(left_gcm[i - 1], right_gcm[i + 1]))
print(maxgcm)

-alist.sort() -def get_custum(xlist): +def listup_gcm(xlist): +    list_gcm = [] -    gcm_list = [] -            gcm_list.append(a) +            list_gcm.append(a) -        ret = calc_gcm(a, prev) -        gcm_list.append(ret) -        prev = ret -    for boundary, gcm in enumerate(gcm_list): -        if gcm == gcm_list[-1]: -            break -    gcm_1 = None -    for i, a in enumerate(xlist): -        if i == boundary - 1: -            continue -        if gcm_1 is None: -            gcm_1 = a -            continue -        gcm_1 = calc_gcm(a, gcm_1) -    gcm_2 = None -    for i, a in enumerate(xlist): -        if i == boundary: -            continue -        if gcm_2 is None: -            gcm_2 = a -            continue -        gcm_2 = calc_gcm(a, gcm_2) -    return max(gcm_1, gcm_2) +        gcm = calc_gcm(prev, a) +        list_gcm.append(gcm) +        prev = gcm +    return list_gcm -ret1 = get_custum(alist) +left_gcm = listup_gcm(alist) -ret2 = get_custum(alist) -print((max(ret1, ret2))) +right_gcm = listup_gcm(alist) +right_gcm.reverse() +maxgcm = 0 +for i in range(n): +    if i == 0: +        maxgcm = max(maxgcm, right_gcm[1]) +    elif i == n - 1: +        maxgcm = max(maxgcm, left_gcm[n - 2]) +    else: +        maxgcm = max(maxgcm, calc_gcm(left_gcm[i - 1], right_gcm[i + 1])) +print(maxgcm)