let p = Array.init (read_int ()) (fun _ -> Scanf.scanf " %d" (fun i -> i))
let _, j, s = Array.fold_left (fun (i, j, s) p -> if p = i then (i + 1, j + 1, s) else (i + 1, 0, s + (j + 1) / 2)) (1, 0, 0) p
let () = Printf.printf "%d\n" (s + (j + 1) / 2)
