import scala.io.{StdIn => in}

object Main extends App {
  val n = in.readInt
  val a = in.readLine.split(" ").map(_.toInt).sorted

  // def fact(n:Int):Int = {
  //   if(n == 1) 1
  //   else  n * fact(n-1)
  // }
  val p = a.last
  val d = a./:(Int.MaxValue, -1) {
    case ((min,r),i) => {
      val x = (i - (p-i)).abs
      if(x < min) (x, i)
      else (min, r)
    }
  }._2
  println(p + " " + d)
}