let string_to_list str n cut = let rec move_element pos ls = if List.length ls = n - 1 then let last_int = int_of_string (String.sub str (pos + 1) ((String.length str - 1) - pos)) in last_int :: ls else let pos1 = String.index_from str (pos + 1) cut in let strint = String.sub str (pos + 1) (pos1 - pos - 1) in let int = int_of_string strint in let newls = int :: ls in move_element pos1 newls in let first_pos = String.index_from str 0 cut in let first_int = int_of_string (String.sub str 0 first_pos) in move_element first_pos [first_int] let median n ls = let ls_sorted = List.fast_sort compare ls in if n mod 2 = 0 then (float_of_int ((List.nth ls_sorted ((n/2) - 1)) + (List.nth ls_sorted ((n/2 + 1) - 1)))) /. 2. else float_of_int (List.nth ls_sorted (((n + 1) / 2) - 1)) let () = let n = int_of_string (read_line ()) in let args = read_line () in print_float (median n (string_to_list args n ' ')); print_string "\n"