import Control.Applicative( (<$>))
import Data.List
import qualified Data.List as L
import Data.ByteString.Char8
import qualified Data.ByteString.Char8 as C8
import Data.Maybe( fromJust)


main = do
    let
	readBS2Int = fst . fromJust . C8.readInt
	readLine2Ints = Prelude.map readBS2Int . C8.words <$>
							C8.getLine
    _n_ <- readLn::IO Int
    ps_ <- readLine2Ints
    let
	chk (one,two) _ []	= (one,two)
	chk (one,two) i [p]
	  | i==p		= (one+1,two)
	  | otherwise		= (one,two)
	chk (one,two) i (p1:tl@(p2:ps))
	  | i==p1 && i+1==p2	= chk (one,two+1) (i+2) ps
	  | i==p1		= chk (one+1,two) (i+2) ps
	  | otherwise		= chk (one,two) (i+1) tl
	
	(one,two) = chk (0,0) 1 ps_

    print $ one + two