
data State = N | I | R deriving Eq

main :: IO ()
main = do
  _ <- readLn :: IO Int
  ls <- fmap read . words <$> getLine :: IO [Int]
  print $ solve 0 1 ls
solve :: Int -> Int -> [Int] -> Int
solve c _ [] = c
solve c idx (h:tl) = solve c' idx' tl' where
  s = if h == idx then if head tl == idx + 1 then R else I else N
  c' = if s == N then c else c + 1
  idx' = if s == R then idx + 2 else idx + 1
  tl' = if s == R then tail' tl else tl

tail' :: [a] -> [a]
tail' [] = []
tail' ls = tail ls
