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

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

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

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

b(2) = minval(a(1:n))

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

end program