import Text.Printf
import Data.List

main = do
  s1 <- getLine
  s2 <- getLine
  let l = sort . map (read :: String->Int) $ words s2
  putStr $ show $ head l
  ;putStr " "
  ;putStr $ show $ last l
  ;putStr " "
  ;putStrLn $ show $ sum l