import java.util.*

fun main(args: Array<String>){

    //var (K,T) = readLine()!!.split(" ").map{it.toInt()}
    var n = readLine()!!.toInt()
    var a = readLine()!!.split(" ").map{it.toInt()}
    var max = 0
    for(i in a.indices){
        max = Math.max(a[i],max)
    }

    var rMax = -1
    var rMaxIndex = 0
    for(i in a.indices){
        if(a[i] != max){
            var r = Math.min(a[i],max-a[i])

            if(r>rMax){
                rMaxIndex = i
                rMax = r
            }
        }
    }
    print("$max ${a[rMaxIndex]}")


}
