import Control.Applicative
import Control.Monad
import Data.List
import Data.Maybe


main :: IO()
main = do
    _ <- getLine
    nums <- map read . words <$> getLine
    putStrLn $ solve nums

solve :: [Int] -> String
solve nums =
    case maxCombPair of
        (_, (a1', a2')) -> show a1' ++ " " ++ show a2'
    where
        pairs = [(a1, a2) | a1 <- nums, a2 <- nums, a1 > a2]
        maxCombPair = foldl (\temp pair -> if (fromJust $ comb pair) > fst temp then (fromJust $ comb pair, pair) else temp) (0, (0, 0)) pairs

comb :: (Int, Int) -> Maybe Int
comb (a1, a2)
    | a1 <= a2 = Nothing
    | a2 == 0 = Just 1
    | a1 - a2 < a2 = comb (a1, a1 - a2)
    | otherwise = Just $ (foldl1 (*) . take a2 $ reverse [0..a1]) `div` (foldl1 (*) [1..a2])