import copy



N = int(eval(input()))

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





def gcd(a, b):

    while b:

        a, b = b, a % b

    return a





def calc(B):

    lo, hi = 1, 10 ** 9 + 1

    while abs(hi - lo) > 1:

        X = copy.deepcopy(B)

        m = (hi + lo) // 2



        skipped = False

        while len(X) > 1:

            a, b = X.pop(), X.pop()

            GCD = gcd(a, b)

            if GCD < m:

                if skipped is False:

                    skipped = True

                    X.append(a)

                    continue

                else:

                    hi = m

                    break

            X.append(GCD)

        else:

            if X[0] >= m:

                lo = m

            else:

                hi = m

    return lo





ans1 = calc(A)

ans2 = calc(A[::-1])



print((max(ans1, ans2)))

from fractions import gcd

N = int(eval(input()))

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



front, back = [0], [0]

for a in A:

    front.append(gcd(front[-1], a))

front.append(0)

for a in A[::-1]:

    back.append(gcd(back[-1], a))

back = [0] + back[::-1]





ans = 0

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

    ans = max(ans, gcd(front[i - 1], back[i + 1]))

print(ans)

import copy

N = int(eval(input()))
A = sorted(list(map(int, input().split())))


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


def calc(B):
    lo, hi = 1, 10**9 + 1
    while abs(hi - lo) > 1:
        X = copy.deepcopy(B)
        m = (hi + lo) // 2
        skipped = False
        while len(X) > 1:
            a, b = X.pop(), X.pop()
            GCD = gcd(a, b)
            if GCD < m:
                if skipped is False:
                    skipped = True
                    X.append(a)
                    continue
                else:
                    hi = m
                    break
            X.append(GCD)
        else:
            if X[0] >= m:
                lo = m
            else:
                hi = m
    return lo


ans1 = calc(A)
ans2 = calc(A[::-1])
print((max(ans1, ans2)))

from fractions import gcd

N = int(eval(input()))
A = list(map(int, input().split()))
front, back = [0], [0]
for a in A:
    front.append(gcd(front[-1], a))
front.append(0)
for a in A[::-1]:
    back.append(gcd(back[-1], a))
back = [0] + back[::-1]
ans = 0
for i in range(1, N + 1):
    ans = max(ans, gcd(front[i - 1], back[i + 1]))
print(ans)

-import copy +from fractions import gcd -A = sorted(list(map(int, input().split()))) - - -def gcd(a, b): -    while b: -        a, b = b, a % b -    return a - - -def calc(B): -    lo, hi = 1, 10**9 + 1 -    while abs(hi - lo) > 1: -        X = copy.deepcopy(B) -        m = (hi + lo) // 2 -        skipped = False -        while len(X) > 1: -            a, b = X.pop(), X.pop() -            GCD = gcd(a, b) -            if GCD < m: -                if skipped is False: -                    skipped = True -                    X.append(a) -                    continue -                else: -                    hi = m -                    break -            X.append(GCD) -        else: -            if X[0] >= m: -                lo = m -            else: -                hi = m -    return lo - - -ans1 = calc(A) -ans2 = calc(A[::-1]) -print((max(ans1, ans2))) +A = list(map(int, input().split())) +front, back = [0], [0] +for a in A: +    front.append(gcd(front[-1], a)) +front.append(0) +for a in A[::-1]: +    back.append(gcd(back[-1], a)) +back = [0] + back[::-1] +ans = 0 +for i in range(1, N + 1): +    ans = max(ans, gcd(front[i - 1], back[i + 1])) +print(ans)