import sys

from functools import lru_cache

sys.setrecursionlimit(1000000)



@lru_cache(maxsize=None)

def main():



    def gcd(a, b):

        if b == 0:

            return a

        if a % b == 0:

            return b

        else:

            return gcd(b, a % b)



    N, *A = list(map(int, sys.stdin.read().split()))

    L = [0] * (N + 2)

    R = [0] * (N + 2)

    for i in range(N):

        L[i + 2] = gcd(L[i + 1], A[i])

        R[-i - 2] = gcd(R[-i - 1], A[-i - 1])



    print((max(gcd(L[i], R[i + 1]) for i in range(1, N + 1))))



if __name__=='__main__':

  main()
import sys

from functools import lru_cache

sys.setrecursionlimit(1000000)



@lru_cache(maxsize=None)

def main():



    def gcd(a,b):

        if b>a:

            a,b=b,a

        while b:

            a,b=b, a%b

        return a



    def cul(n,x):

        l=len(x)

        b=[x[i] for i in range(l)]

        b.pop(n)

        tmp=b[0]

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

            tmp=gcd(tmp,b[i])

        return tmp



    N, *a = list(map(int, sys.stdin.read().split()))

    p=50

    if p>N: p=N



    ans=0

    for i in range(p):

        s=cul(i,a[:p])

        if s>ans: ans=s

    print(ans)



if __name__=='__main__':

  main()
import sys
from functools import lru_cache

sys.setrecursionlimit(1000000)


@lru_cache(maxsize=None)
def main():
    def gcd(a, b):
        if b == 0:
            return a
        if a % b == 0:
            return b
        else:
            return gcd(b, a % b)

    N, *A = list(map(int, sys.stdin.read().split()))
    L = [0] * (N + 2)
    R = [0] * (N + 2)
    for i in range(N):
        L[i + 2] = gcd(L[i + 1], A[i])
        R[-i - 2] = gcd(R[-i - 1], A[-i - 1])
    print((max(gcd(L[i], R[i + 1]) for i in range(1, N + 1))))


if __name__ == "__main__":
    main()

import sys
from functools import lru_cache

sys.setrecursionlimit(1000000)


@lru_cache(maxsize=None)
def main():
    def gcd(a, b):
        if b > a:
            a, b = b, a
        while b:
            a, b = b, a % b
        return a

    def cul(n, x):
        l = len(x)
        b = [x[i] for i in range(l)]
        b.pop(n)
        tmp = b[0]
        for i in range(1, l - 1):
            tmp = gcd(tmp, b[i])
        return tmp

    N, *a = list(map(int, sys.stdin.read().split()))
    p = 50
    if p > N:
        p = N
    ans = 0
    for i in range(p):
        s = cul(i, a[:p])
        if s > ans:
            ans = s
    print(ans)


if __name__ == "__main__":
    main()

-        if b == 0: -            return a -        if a % b == 0: -            return b -        else: -            return gcd(b, a % b) +        if b > a: +            a, b = b, a +        while b: +            a, b = b, a % b +        return a -    N, *A = list(map(int, sys.stdin.read().split())) -    L = [0] * (N + 2) -    R = [0] * (N + 2) -    for i in range(N): -        L[i + 2] = gcd(L[i + 1], A[i]) -        R[-i - 2] = gcd(R[-i - 1], A[-i - 1]) -    print((max(gcd(L[i], R[i + 1]) for i in range(1, N + 1)))) +    def cul(n, x): +        l = len(x) +        b = [x[i] for i in range(l)] +        b.pop(n) +        tmp = b[0] +        for i in range(1, l - 1): +            tmp = gcd(tmp, b[i]) +        return tmp + +    N, *a = list(map(int, sys.stdin.read().split())) +    p = 50 +    if p > N: +        p = N +    ans = 0 +    for i in range(p): +        s = cul(i, a[:p]) +        if s > ans: +            ans = s +    print(ans)