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

    val B = Array(N + 1) {0L}
    val C = Array(N + 1) {0L}

    for (i in A.indices) {
        B[i + 1] = gcd(A[i], B[i])
    }
    for (i in A.indices.reversed()) {
        C[i] = gcd(C[i + 1], A[i])
    }

    var res = 0L
    for (i in A.indices) {
        res = Math.max(res, gcd(B[i], C[i + 1]))
    }
    println(res)
}

/**
 * Calculate the greatest common divisor of `x` and `y` with Euclidean algorithm
 */
tailrec fun gcd(x: Long, y: Long): Long = if (y == 0L) x else gcd(y, x % y)
