import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as B
import Data.Char

set :: VU.Vector Int -> Int -> Int
set vec acc
  | VU.length vec == 1 = acc + 1
  | otherwise = 
    case compare a b of
      LT -> trav vec 1 acc
      EQ -> set ts acc
      GT -> trav vec 0 acc
  where
    a = VU.head vec
    b = vec VU.! 1
    ts = VU.tail vec

trav :: VU.Vector Int -> Int -> Int -> Int 
trav vec mode acc 
  | VU.length vec == 1 = acc + 1
  | (mode == 1) && (a <= b) = trav ts mode acc
  | (mode == 0) && (a >= b) = trav ts mode acc
  | otherwise = set ts (acc + 1)
  where
    a = VU.head vec
    b = vec VU.! 1
    ts = VU.tail vec

main = do
  n <- readLn :: IO Int
  vec <- VU.unfoldrN n (B.readInt . B.dropWhile isSpace) <$> B.getLine
  print $ set vec 0

