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

    val max = aa.last()
    val target = max/2

    val idx = upperBound(aa.toIntArray(), target, 0, n-1)

    if (idx < 0) {
        println("$max ${aa[0]}")
        return
    }

    if (aa[idx] == target) {
        println("$max $target")
        return
    }

    val lDiff = target - aa[idx]
    val uDiff = target - (max - aa[idx+1])

    if (lDiff <= uDiff) {
        println("$max ${aa[idx]}")
    } else {
        println("$max ${aa[idx+1]}")
    }
}

fun upperBound(list: IntArray, key: Int, start: Int, end: Int): Int {
    var minIdx = start-1
    var maxIdx = end+1

    while (maxIdx - minIdx > 1) {
        val mid = minIdx + (maxIdx - minIdx)/2
        if (list[mid] > key) {
            maxIdx = mid
        } else {
            minIdx = mid
        }
    }

    return minIdx
}