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

data Mode = Inc | Dec deriving Eq

set :: VU.Vector Int -> Int -> Int
set vec acc
  | VU.length vec == 1 = acc + 1
  | otherwise = 
    case compare a b of
      LT -> trav vec Inc acc
      GT -> trav vec Dec acc
  where
    a = VU.head two
    b = VU.last two
    two = VU.take 2 vec

trav :: VU.Vector Int -> Mode -> Int -> Int 
trav vec mode acc 
  | VU.length vec == 1 = acc + 1
  | (mode == Inc) && (a <= b) = trav ts mode acc
  | (mode == Dec) && (a >= b) = trav ts mode acc
  | otherwise = set ts (acc+1)
  where
    a = VU.head two
    b = VU.last two
    two = VU.take 2 vec
    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

