program ABC_094_D_BinomialCoefficients
   implicit none
   integer n, l, r, i
   integer, allocatable :: a(:)
   read(*, *) n
   allocate(a(1: n))
   read(*, *) a(1: n)
   l = maxval(a(1:n))
   r = a(1)
   do i = 2, n
       if( abs(dble(l/2) - r) >= abs(dble(l/2) - a(i)) .and. a(i) /= l) then
	       r = a(i)
	   end if
   end do
   write(*, *) l, r 
end program ABC_094_D_BinomialCoefficients