def slove():

    import sys

    import fractions

    input = sys.stdin.readline

    n = int(input().rstrip('\n'))

    a = list(map(int, input().rstrip('\n').split()))

    g_l = [[0, 0] for _ in range(n + 1)]



    for i in range(n):

        g_l[i+1][0] = fractions.gcd(g_l[i][0], a[i])

        g_l[-i-2][1] = fractions.gcd(g_l[-i-1][1], a[-i-1])

    m_g = 0

    for i in range(n):

        m_g = max(m_g, fractions.gcd(g_l[i][0], g_l[i + 1][1]))

    print(m_g)





if __name__ == '__main__':

    slove()

def slove():

    import sys

    import fractions

    input = sys.stdin.readline

    n = int(input().rstrip('\n'))

    a = list(map(int, input().rstrip('\n').split()))

    ls = [[0] * (n + 1) for _ in range(2)]

    for i in range(n):

        ls[0][i+1] = fractions.gcd(ls[0][i], a[i])

        ls[1][-i-2] = fractions.gcd(ls[1][-i-1], a[-i-1])

    m_gcd = 0

    for i in range(n):

        gcd = fractions.gcd(ls[0][i], ls[1][i+1])

        m_gcd = max(m_gcd, gcd)

    print(m_gcd)





if __name__ == '__main__':

    slove()

def slove():
    import sys
    import fractions

    input = sys.stdin.readline
    n = int(input().rstrip("\n"))
    a = list(map(int, input().rstrip("\n").split()))
    g_l = [[0, 0] for _ in range(n + 1)]
    for i in range(n):
        g_l[i + 1][0] = fractions.gcd(g_l[i][0], a[i])
        g_l[-i - 2][1] = fractions.gcd(g_l[-i - 1][1], a[-i - 1])
    m_g = 0
    for i in range(n):
        m_g = max(m_g, fractions.gcd(g_l[i][0], g_l[i + 1][1]))
    print(m_g)


if __name__ == "__main__":
    slove()

def slove():
    import sys
    import fractions

    input = sys.stdin.readline
    n = int(input().rstrip("\n"))
    a = list(map(int, input().rstrip("\n").split()))
    ls = [[0] * (n + 1) for _ in range(2)]
    for i in range(n):
        ls[0][i + 1] = fractions.gcd(ls[0][i], a[i])
        ls[1][-i - 2] = fractions.gcd(ls[1][-i - 1], a[-i - 1])
    m_gcd = 0
    for i in range(n):
        gcd = fractions.gcd(ls[0][i], ls[1][i + 1])
        m_gcd = max(m_gcd, gcd)
    print(m_gcd)


if __name__ == "__main__":
    slove()

-    g_l = [[0, 0] for _ in range(n + 1)] +    ls = [[0] * (n + 1) for _ in range(2)] -        g_l[i + 1][0] = fractions.gcd(g_l[i][0], a[i]) -        g_l[-i - 2][1] = fractions.gcd(g_l[-i - 1][1], a[-i - 1]) -    m_g = 0 +        ls[0][i + 1] = fractions.gcd(ls[0][i], a[i]) +        ls[1][-i - 2] = fractions.gcd(ls[1][-i - 1], a[-i - 1]) +    m_gcd = 0 -        m_g = max(m_g, fractions.gcd(g_l[i][0], g_l[i + 1][1])) -    print(m_g) +        gcd = fractions.gcd(ls[0][i], ls[1][i + 1]) +        m_gcd = max(m_gcd, gcd) +    print(m_gcd)