program test
implicit none
integer :: n,a(10**5),b(2),c(10**5),i,min_c = 10**9

read(*,*) n
read(*,*) (a(i),i=1,n)

b(1) = maxval(a(1:n))

a(maxloc(a(1:n))) = 0

do i = 1, n
 if (abs(a(i)-b(1)) >= a(i)) then
   c(i) = abs(a(i)-b(1))
 else
   c(i) = a(i)
 endif
   if(min_c >= c(i)) then 
     min_c = c(i)
	 b(2) = a(i)
   endif
enddo
 

write(*,*) b(1),b(2)
 
end program