let hist xs =
  let h = Hashtbl.create 8 in
  List.iter (fun x ->
    let n = match Hashtbl.find_opt h x with
            | Some n -> n + 1
            | None -> 1
    in
    Hashtbl.replace h x n
  ) xs;
  h

let max_value h =
  Hashtbl.fold (fun _ v acc -> if v > acc then v else acc) h 0

let total h =
  Hashtbl.fold (fun _ v acc -> acc + v) h 0

;;

let h = hist [1;2;3;1;4;5;1;2;6;7;1;8;9;1;0] in
total h * max_value h
