let N = stdin.ReadLine() |> int
let A = stdin.ReadLine().Split() |> Array.map int |> Array.toList

let rec loop i items count =
    match items with
    | [head] -> if head = i then count + 1 else count
    | head :: [tail] -> 
        if head = i 
        then loop (i + 1) [head] (count + 1)
        else loop (i + 1) [tail] count
    | head :: sec :: tail -> 
        if i = head 
        then loop (i + 1) (head::tail) (count + 1) 
        else loop (i + 1) (sec::tail) count

loop 1 A 0 |> stdout.WriteLine