object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt()
  val a = Array.fill(n)(sc.nextInt())
  val sorted = a.sorted
  val max = sorted.apply(n-1)
  val ans2 = if (max%2!=0) {
    val mid1 = a.filter(x=>x!=max).map(i => (i, Math.abs(i - (max+1) / 2))).sortWith((x, y) => x._2 < y._2).apply(0)
    val mid2 = a.filter(x=>x!=max).map(i => (i, Math.abs(i - (max-1) / 2))).sortWith((x, y) => x._2 < y._2).apply(0)
    if (mid1._2>mid2._2){
      mid1._1
    }else{
      mid2._1
    }
  } else{
    val mid = a.filter(x=>x!=max).map(i => (i, Math.abs(i - max / 2))).sortWith((x, y) => x._2 < y._2).apply(0)
    mid._1
  }
  printf("%d %d",max,ans2)
  println()
}