open Scanf ;; open Printf ;; exception Impossible ;; let input_int () = scanf " %d" (fun x -> x) ;; let input_ints n = List.init n (fun _ -> input_int ()) ;; let rec last a = match a with | [] -> raise Impossible | [x] -> x | (x :: xs) -> last xs ;; let () = let n = input_int () in let a = input_ints n in if List.hd a > last a then print_endline "No" else begin print_endline "Yes"; let rec loop b = begin match b with | [] -> raise Impossible | (x :: []) -> [x] | (x :: y :: []) -> if x > y then raise Impossible else begin printf "%d " x; [y] end | (x :: y :: xs) -> if x < y then begin printf "%d " y; loop (x :: xs) end else loop (x :: loop (y :: xs)) end in loop a |> ignore end