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

    val frontgcd = IntArray(n)
    frontgcd[0] = a[0]
    for(i in 1..n-1){
        frontgcd[i]=gcd(a[i],frontgcd[i-1])
    }

    val backgcd = IntArray(n)
    backgcd[n-1] = a[n-1]
    for(i in n-2 downTo 0){
        backgcd[i]=gcd(a[i],backgcd[i+1])
    }

    (0..n-1).map { when(it){
        0 -> backgcd[1]
        n-1 -> frontgcd[n-2]
        else -> gcd(frontgcd[it-1],backgcd[it+1])
    } }.max().let { println(it) }
}

fun gcd(a: Int, b: Int): Int = if(b==0) a else gcd(b,a%b)