import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*

class segTree<Monoid>(private val n: Int, private val op: (Monoid, Monoid) -> Monoid, private val e: Monoid){
    private var d: MutableList<Monoid>
    private var size = 1
    private var log = 0

    init {
        while (size < n) {
            size *= 2
            log++
        }
        d = MutableList(2 * size) { e }
    }

    constructor(n: Int, op: (Monoid, Monoid) -> Monoid, e: Monoid, a: Array<Monoid>) : this(n, op, e) {
        for (i in 0 until n) {
            d[size + i] = a[i]
        }
        for (i in size - 1 downTo 1) {
            update(i)
        }
    }

    operator fun set(p: Int, x: Monoid) {
        if (p !in 0 until n) {
            throw Exception()
        }
        val p = p + size
        d[p] = x
        for (i in 1..log) {
            update(p shr i)
        }
    }

    operator fun get(p: Int): Monoid {
        if (p !in 0 until n) {
            throw Exception()
        }
        return d[p + size]
    }

    fun prod(l: Int, r: Int): Monoid {
        if (l !in 0..r || r !in l..n) {
            throw Exception()
        }
        var sml = e
        var smr = e
        var l = l + size
        var r = r + size
        while (l < r) {
            if (l and 1 != 0) sml = op(sml, d[l++])
            if (r and 1 != 0) smr = op(d[--r], smr)
            l /= 2
            r /= 2
        }
        return op(sml, smr)
    }

    fun allProd(): Monoid {
        return d[1]
    }

    fun maxRight(l: Int, f: (Monoid) -> Boolean): Int {
        if (l !in 0..n || !f(e)) {
            throw Exception()
        }
        if (l == n) return n
        var l = l + size
        var sm = e
        do {
            while (l % 2 == 0) l /= 2
            if (!f(op(sm, d[l]))) {
                while (l < size) {
                    l = 2 * l
                    if (f(op(sm, d[l]))) {
                        sm = op(sm, d[l])
                        l++
                    }
                }
                return l - size
            }
            sm = op(sm, d[l])
            l++
        } while ((l and -l) != l)
        return n
    }

    fun minLeft(r: Int, f: (Monoid) -> Boolean): Int {
        if (r !in 0..n || !f(e)) {
            throw Exception()
        }
        if (r == 0) return 0
        var r = r + size
        var sm = e
        do {
            r--
            while (r > 1 && r % 2 != 0) r /= 2
            if (!f(op(d[r], sm))) {
                while (r < size) {
                    r = 2 * r + 1
                    if (f(op(d[r], sm))) {
                        sm = op(d[r], sm)
                        r--
                    }
                }
                return r + 1 - size
            }
            sm = op(d[r], sm)
        } while ((r and -r) != r)
        return 0
    }

    private fun update(k: Int) {
        d[k] = op(d[2 * k], d[2 * k + 1])
    }
}

fun gcd(a:Int, b:Int):Int {
    if (a == 0) return b
    if (b == 0) return a
    val c = a % b
    if (c == 0) return b
    return gcd(b, c)
}

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextInt()
    val a = Array(n) { sc.nextInt() }
    var max = 0
    val seg = segTree(n, ::gcd, 0, a)
    for (i in 0 until n) {
        max = maxOf(max, gcd(seg.prod(0, i), seg.prod(i + 1, n)))
    }
    println(max)
}

fun main() {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

Measured memory_bytes: 60192