fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(" ").map { it.toLong() }

    val leftGcd = Array(n + 1) { 0L }
    val rightGcd = Array(n + 1) { 0L }

    for (i in 0 until n) {
        leftGcd[i + 1] = gcd(leftGcd[i], a[i])
    }

    for (i in n - 1 downTo 0) {
        rightGcd[i] = gcd(rightGcd[i + 1], a[i])
    }

    var ans = 0L
    for (i in 0 until n) {
        val left = leftGcd[i]
        val right = rightGcd[i + 1]
        ans = Math.max(ans, gcd(left, right))
    }

    println(ans)
}

fun gcd(a: Long, b: Long): Long {
    if (b == 0L) return a

    return gcd(b, a % b)
}