asc :: [Int] -> Int -> Int
asc [] acc = acc
asc (x:xs) acc
  | xs == [] = acc
  | x <= head xs = asc xs acc
  | otherwise = solve xs acc

desc :: [Int] -> Int -> Int
desc [] acc = acc
desc (x:xs) acc
  | xs == [] = acc
  | x >= head xs = desc xs acc
  | otherwise = solve xs acc

solve :: [Int] -> Int -> Int
solve [] acc = acc
solve (x:xs) acc
  | xs == [] = acc + 1
  | x == head xs = solve xs acc
  | x < head xs = asc xs (acc + 1)
  | otherwise = desc xs (acc + 1)

main = do
  n <- getLine
  line <- getLine
  let as = fmap (read :: String -> Int) (words line) in
    putStrLn $ show $ solve as 0
