my_max :: Ord a => [a]->a

my_max [x] = x
my_max (x:xs) = 
  if x > tmp_max then
    x
  else
    tmp_max

  where
    tmp_max = my_max xs

my_min :: Ord a => [a]->a

my_min [x] = x
my_min (x:xs) = 
  if x < tmp_min then
    x
  else
    tmp_min

  where
    tmp_min = my_min(xs)

my_sum :: Num a => [a]->a

my_sum [x] = x
my_sum (x:xs) = 
  x + my_sum xs

main = do
  n <- getLine
  str_list <- getLine
  let list = map (read :: String->Int) $ words str_list

  let max_list = my_max list
  let min_list = my_min list
  let sum_list = my_sum list

  putStr $ show min_list
  putChar ' '
  putStr $ show max_list
  putChar ' '
  putStr $ show sum_list
  putChar ' '