import Data.List

main :: IO ()
main = do
    n <- (read :: String -> Int) <$> getLine
    as <- map read . words <$> getLine
    putStrLn . unwords . map show . binominalCoefficients $ as

nearest n = foldr1 near
    where
        near a b
            | abs (n - a) < abs (n - b) = a
            | abs (n - a) > abs (n - b) = b
            | otherwise                 = if a <= b then a else b

binominalCoefficients as =
    if even ai
        then [ai, nearest (ai `div` 2) as]
        else [ai, nearest ((ai + 1) `div` 2) as]
    where
        ai = maximum as