import fractions





def main():

    N = int(eval(input()))

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



    gcd_ans = []

 

    l = [0] * N

    r =[0] * N

    for i in range(N-1):

        l[i+1] = fractions.gcd(l[i],A[i])

        r[i+1] = fractions.gcd(r[i],A[N-1-i])

    r.reverse()

 

    for i in range(N):

        gcd_ans.append(fractions.gcd(l[i],r[i]))

 

    print((max(gcd_ans)))





main()
from math import gcd



def main():

    N = int(eval(input()))

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

    R = [0] * (N+1)

    L = [0] * (N+1)

    for i in range(N):

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



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

        R[i] = gcd(R[i+1], A[i])

    ans = 0

    for i in range(N):

        ans = max(ans, gcd(L[i],R[i+1]))

    print(ans)



if __name__ == "__main__":

    main()
import fractions


def main():
    N = int(eval(input()))
    A = list(map(int, input().split()))
    gcd_ans = []
    l = [0] * N
    r = [0] * N
    for i in range(N - 1):
        l[i + 1] = fractions.gcd(l[i], A[i])
        r[i + 1] = fractions.gcd(r[i], A[N - 1 - i])
    r.reverse()
    for i in range(N):
        gcd_ans.append(fractions.gcd(l[i], r[i]))
    print((max(gcd_ans)))


main()

from math import gcd


def main():
    N = int(eval(input()))
    A = list(map(int, input().split()))
    R = [0] * (N + 1)
    L = [0] * (N + 1)
    for i in range(N):
        L[i + 1] = gcd(L[i], A[i])
    for i in range(N - 1, -1, -1):
        R[i] = gcd(R[i + 1], A[i])
    ans = 0
    for i in range(N):
        ans = max(ans, gcd(L[i], R[i + 1]))
    print(ans)


if __name__ == "__main__":
    main()

-import fractions +from math import gcd -    gcd_ans = [] -    l = [0] * N -    r = [0] * N -    for i in range(N - 1): -        l[i + 1] = fractions.gcd(l[i], A[i]) -        r[i + 1] = fractions.gcd(r[i], A[N - 1 - i]) -    r.reverse() +    R = [0] * (N + 1) +    L = [0] * (N + 1) -        gcd_ans.append(fractions.gcd(l[i], r[i])) -    print((max(gcd_ans))) +        L[i + 1] = gcd(L[i], A[i]) +    for i in range(N - 1, -1, -1): +        R[i] = gcd(R[i + 1], A[i]) +    ans = 0 +    for i in range(N): +        ans = max(ans, gcd(L[i], R[i + 1])) +    print(ans) -main() +if __name__ == "__main__": +    main()