Scanf.scanf "%d" (fun n ->
    let p = Array.init n (fun _ -> Scanf.scanf " %d" (fun p -> p)) in

    let rec loop i mm acc =
        if i = n then acc else
            if p.(i) < mm then loop (i + 1) p.(i) (acc + 1)
                          else loop (i + 1) mm acc
    in
    loop 1 p.(0) 1 |> Printf.printf "%d\n"
)