fun main(args: Array<String>) = println(run {
    tailrec fun gcd(a: Int, b: Int): Int = if (b == 0) a else gcd(b, a % b)
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(" ").map { it.toInt() }

    val l = IntArray(n)
    val r = IntArray(n)
    l[0] = a.first()
    r[n-1] = a.last()
    for (i in 1..l.lastIndex) {
        val j = r.lastIndex-i
        l[i] = gcd(l[i-1], a[i])
        r[j] = gcd(r[j+1], a[j])
    }
    
    ((1..n-2).map { i ->
        gcd(l[i-1], r[i+1])
    }+l[n-2]+r[1]).max()!!

})

