import           Control.Applicative
import           Control.Exception
import           Data.Char
import           System.IO.Error
import           Text.Printf

main :: IO ()
main = do
  n <- readLn
  first <- readWd
  (min,max,sum) <- solve (n-1) (first, first, first)
  printf "%d %d %d\n" min max sum

solve
  :: Int
  -> (Int, Int, Int)
  -> IO (Int, Int, Int)
solve 0 result        = pure result
solve n (min,max,sum) = do
  x <- readWd
  solve (n-1)
    $ if x < min
      then (x,max,sum+x)
      else if x > max
           then (min,x,sum+x)
           else (min,max,sum+x)

readWd :: Read a => IO a
readWd = getWord >>= readIO

getWord :: IO String
getWord = handle handleEOF $ do
  c <- getChar
  if isSpace c then pure [] else (c:) <$> getWord
  where
    handleEOF e = if isEOFError e then pure [] else throwIO e

