import java.util.*
import java.math.*
fun main(args: Array<String>) {

    val N = readLine()!!.toInt()
    //val N = readLine()!!.split("").map{it.toInt()}
    val A = readLine()!!.split(" ").map{it.toLong()}
    //val S = readLine()!!

    if (N == 2) {
        println(Math.max(A[0],A[1]))
        return
    }

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

    var ans = longArrayOf(0,0)
    ans[0] = gcd(gcd(A[0],A[1]),A[2])
    ans[1] = longArrayOf(gcd(A[0],A[1]),gcd(A[0],A[2]),gcd(A[1],A[2])).max()!!
    for (i in 3 until N) {
        ans[1] = Math.max(gcd(ans[1],A[i]),ans[0])
        ans[0] = gcd(ans[0],A[i])
    }


    println(ans.max());
}
