
fOdd :: Int->Int->Int
fOdd m x=if x<=m then m-x else x-m-1

fEve :: Int -> Int -> Int
fEve m x=if x<=m then m-x else x-m

f ::(Int->Int->Int)-> Int->(Int,Int)-> [Int]->Int
f _ _ (_,ans) []=ans
f f2 m (d,ans) (x:xs)=
    let d1=f2 m x
    in if d1<=d then f f2 m (d1,x) xs else f f2 m (d,ans) xs


main =do
      e<-getLine
      es<-getLine
      let n=read e::Int
          xs=map read (words es)::[Int]
          m1=maximum xs
          m2=m1 `div` 2
      putStr $ (show m1) ++ " "
      putStrLn $ show $ if n `mod` 2==0 then f fEve m2 (m1,m1) xs else f fOdd m2 (m1,m1) xs