let n = read_int ()

let rec f i j s =
  if i = n then s + (j + 1) / 2
  else
    Scanf.scanf " %d" (fun p ->
      if p = i + 1 then f (i + 1) (j + 1) s
      else f (i + 1) 0 (s + (j + 1) / 2)
    )

let () = Printf.printf "%d\n" (f 0 0 0)
