fun longList() = readLine()?.split(" ")?.map(String::toLong) ?: TODO()
fun main(args: Array<String>) {
    val n = readLine()?.toInt() ?: return
    val a = longList().sorted()
    val s = a.last()

    var max = 0L
    var index = 0
    a.forEachIndexed { i, r ->
        val nr = s - r
        if (max < r * nr) {
            index = i
            max = r * nr
        }
    }
    println("$s ${a[index]}")
}
