import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List
import Data.Ord

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    n <- getInt
    (ai:as) <- sortOn Down <$> getIntList
    let aj = solve ai as
    putStr $ show ai
    putStr " "
    putStrLn $ show aj

solve m as | null bs = s
           | null ss = b
           | even m = if mid - s < b - mid then s else b
           | odd m = if mid - s < b - (mid+1) then s else b
    where mid = m `div` 2
          (bs,ss) = span (> mid) as
          b = last bs
          s = head ss