
let () =
  let n = Scanf.sscanf (read_line()) "%d" (fun n -> n) in
  let string_numbers = Str.split (Str.regexp " ") (read_line()) in
  let numbers = List.map int_of_string string_numbers in
  let rec read numbers min max sum n =
    match numbers with
    | [] -> if n != 0 then
              raise (Sys_error ": number of the numbers is wrong");
            min,max,sum
    | h::t -> let new_min = if h < min then h else min in
              let new_max = if h > max then h else max in
              read t new_min new_max (sum + h) (n - 1)
  in
  let min, max, sum = read numbers max_int min_int 0 n in
  Printf.printf "%d %d %d\n" min max sum
;;
