import Control.Monad

main :: IO ()
main = do
  readLn
  strlist <- readLn
  let list = map read $ words strlist
  putStr $ maximum list
  putStr " "
  putStr $ minimum list
  putStr " "
  putStrLn $ sum list
