def gcd(x, y):

    while (y):

        x, y = y, x % y

    return x



n = int(eval(input()))

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

fromLeft = [0] * n

fromLeft[0] = a[0]

fromRight = [0] * n

fromRight[0] = a[n - 1]

for i in range(1, n):

    fromLeft[i] = gcd(fromLeft[i - 1], a[i])

    fromRight[i] = gcd(fromRight[i - 1], a[n - i - 1])

ret = fromLeft[n - 1]

for i in range(n):

    if i == 0:

        curGcd = fromRight[n - 2]

    elif i == n - 1:

        curGcd = fromLeft[n - 2]

    else:

        curGcd = gcd(fromLeft[i - 1], fromRight[n - i - 2])

    ret = max(ret, curGcd)

print(ret)
n = int(eval(input()))

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



def gcd(a, b):

    while b:

        a, b = b, a % b

    return a



fromLeft = [a[0]] + [None] * (n - 1)

for i in range(1, n):

    fromLeft[i] = gcd(fromLeft[i - 1], a[i])

fromRight = [None] * (n - 1) + [a[-1]]

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

    fromRight[i] = gcd(fromRight[i + 1], a[i])

ret = 1

for repr in range(n):

    if repr == 0:

        curGcd = fromRight[repr + 1]

    elif repr == n - 1:

        curGcd = fromLeft[repr - 1]

    else:

        curGcd = gcd(fromLeft[repr - 1], fromRight[repr + 1])

    ret = max(ret, curGcd)

print(ret)

def gcd(x, y):
    while y:
        x, y = y, x % y
    return x


n = int(eval(input()))
a = list(map(int, input().split()))
fromLeft = [0] * n
fromLeft[0] = a[0]
fromRight = [0] * n
fromRight[0] = a[n - 1]
for i in range(1, n):
    fromLeft[i] = gcd(fromLeft[i - 1], a[i])
    fromRight[i] = gcd(fromRight[i - 1], a[n - i - 1])
ret = fromLeft[n - 1]
for i in range(n):
    if i == 0:
        curGcd = fromRight[n - 2]
    elif i == n - 1:
        curGcd = fromLeft[n - 2]
    else:
        curGcd = gcd(fromLeft[i - 1], fromRight[n - i - 2])
    ret = max(ret, curGcd)
print(ret)

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


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


fromLeft = [a[0]] + [None] * (n - 1)
for i in range(1, n):
    fromLeft[i] = gcd(fromLeft[i - 1], a[i])
fromRight = [None] * (n - 1) + [a[-1]]
for i in range(n - 2, -1, -1):
    fromRight[i] = gcd(fromRight[i + 1], a[i])
ret = 1
for repr in range(n):
    if repr == 0:
        curGcd = fromRight[repr + 1]
    elif repr == n - 1:
        curGcd = fromLeft[repr - 1]
    else:
        curGcd = gcd(fromLeft[repr - 1], fromRight[repr + 1])
    ret = max(ret, curGcd)
print(ret)

-def gcd(x, y): -    while y: -        x, y = y, x % y -    return x +n = int(eval(input())) +a = list(map(int, input().split())) -n = int(eval(input())) -a = list(map(int, input().split())) -fromLeft = [0] * n -fromLeft[0] = a[0] -fromRight = [0] * n -fromRight[0] = a[n - 1] +def gcd(a, b): +    while b: +        a, b = b, a % b +    return a + + +fromLeft = [a[0]] + [None] * (n - 1) -    fromRight[i] = gcd(fromRight[i - 1], a[n - i - 1]) -ret = fromLeft[n - 1] -for i in range(n): -    if i == 0: -        curGcd = fromRight[n - 2] -    elif i == n - 1: -        curGcd = fromLeft[n - 2] +fromRight = [None] * (n - 1) + [a[-1]] +for i in range(n - 2, -1, -1): +    fromRight[i] = gcd(fromRight[i + 1], a[i]) +ret = 1 +for repr in range(n): +    if repr == 0: +        curGcd = fromRight[repr + 1] +    elif repr == n - 1: +        curGcd = fromLeft[repr - 1] -        curGcd = gcd(fromLeft[i - 1], fromRight[n - i - 2]) +        curGcd = gcd(fromLeft[repr - 1], fromRight[repr + 1])