import qualified Data.ByteString.Char8 as B
import Data.List

main = do
  _ <- getLine
  as <- map (maybe undefined fst . B.readInt) . B.words <$> B.getLine
  print (sarray as)

sarray as = sum $ unfoldr cut $ groupBy (\x y -> x==y || x==0 || y==0) ds
  where
    ds = map signum $ zipWith (-) (tail as) as

cut [] = Nothing
cut [g] = Just (1, [])
cut [g,[n]] = Just (2, [])
cut (g:[n]:gs) = Just (1, gs)
cut (_:_:gs) = Just (2,gs)