import Debug.Trace (traceShow)

data State = NoneDecreasing | NoneIncreasing | Unknown deriving (Eq, Show)

main = do
    n <- getLine
    xs <- map read . words <$> getLine
    print $ solve xs

solve :: [Int] -> Int
solve xs = length $ foldr fn [] xs
    where fn x [] = ([x], Unknown):[]
          fn x whole@((c, state):ys) | state == NoneDecreasing = if (isNoneDecreasing x c)
                                                                 then (x:c, state):ys
                                                                 else ([x], Unknown):whole
                                     | state == NoneIncreasing = if (isNoneDecreasing x c)
                                                                 then (x:c, state):ys
                                                                 else ([x], Unknown):whole
                                     | otherwise               = if (isNoneDecreasing x c) && (isNoneIncreasing x c)
                                                                 then (x:c, Unknown):ys
                                                                 else if (isNoneDecreasing x c)
                                                                      then (x:c, NoneDecreasing):ys
                                                                      else (x:c, NoneIncreasing):ys
isNoneIncreasing :: Ord a => a -> [a] -> Bool
isNoneIncreasing x (y:_) = not (x > y)
isNoneDecreasing :: Ord a => a -> [a] -> Bool
isNoneDecreasing x (y:_) = not (x < y)