open System let ri () = stdin.ReadLine() |> int let ria () = stdin.ReadLine().Split() |> Array.map int type Sol() = member this.Solve() = let N = ri () let A = ria () let rec f (ar: int[]) i n sum = match i with | -1 -> sum | _ when ar.[i] = n -> f ar (i-1) (n-1) sum | _ -> f ar (i-1) n (sum+1) f A (N-1) N 0 |> printfn "%d" let mySol = new Sol() mySol.Solve()