{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Data.List

data Dir = Up | Down | Unknown deriving Show

solve :: Int -> [Int] -> Int
solve n (a:as) = go 1 Unknown a as
  where
    go !k _ _ [] = k
    go !k Unknown x (y:ys)
        | x <  y    = go k Up      y ys
        | x >  y    = go k Down    y ys
        | otherwise = go k Unknown y ys
    go !k Up x (y:ys)
        | x > y     = go (k + 1) Unknown y ys
        | otherwise = go k Up y ys
    go !k Down x (y:ys)
        | x < y     = go (k + 1) Unknown y ys
        | otherwise = go k Down y ys

main :: IO ()
main = do
    n <- readLn :: IO Int
    as <- fmap read . words <$> getLine :: IO [Int]
    print $ solve n as