fun min(a:Int, b:Int):Int{
    return if (a > b) b else a
}
fun main(args:Array<String>):Unit {
    val n = readLine()!!.toInt()
    val nums = readLine()!!.split(' ').map(String::toInt).sorted().toIntArray()
    val biggest = nums.last()
    var maxMin = 0
    for (a in nums){
        if (min(a, biggest - a) > maxMin){
            maxMin = a
        }
    }
    println("$biggest $maxMin")
}