object Main {

	def main(arg:Array[String]) = {
        var n = scala.io.StdIn.readLine().toInt;
		var list = scala.io.StdIn.readLine().split(" ").map(_.toInt);
  		list.reverse;
        
        val max = list.max;
        val diff = list.filter(_ != max).map(x => math.max(math.abs(max / 2 - x), math.abs((max + 1) / 2 - x))).sorted.head;
        val ans = list.filter(_ != max).filter(x => (diff == math.abs(max / 2 - x)) || (diff == math.abs((max + 1) / 2 - x))).head;
        println(max + " " + ans);
	}

}
