object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt()
  val as = List.fill(n)(sc.nextInt())
  val max = as.max
  val m = as.filter(_ != max).minBy( a =>
    if (max % 2 == 0) (max/2 - a).abs else (max/2 - a).abs.min((max/2 + 1 - a).abs)
  )
  println(s"$max $m")
}
