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

    A.sortBy { it * -1}
    var replaced = false

    var former = A[0]
    var formerGcd = A[0]

    val candidate1 = A.reduce { acc, a ->
        var result = gcd(acc, a)
        if (result == 1L && !replaced) {
            result = listOf(gcd(acc, former),
                    gcd(formerGcd, a)
                    ).max()!!
            replaced = true
        }
        former = a
        formerGcd = acc
        result
    }

    val store = A[1]
    A [1] = A[0]
    val candidate2 = A.reduce { acc, a -> gcd(acc, a)}
    A [1] = store
    A[0] = store
    val candidate3 = A.reduce { acc, a -> gcd(acc, a)}

    println(listOf(candidate1, candidate2, candidate3).max()!!)
}

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