main :: IO()
main = do
    _ <- getLine
    pls <- map read . words <$> getLine
    print $ getsolve pls
    
    
getsolve :: [Int] -> Int
getsolve pls
    | length pls < 3    = 0
    | pls!!1 == maximum( take 3 pls )    = getsolve $ tail pls
    | pls!!1 == minimum( take 3 pls )    = getsolve $ tail pls
    | otherwise                         = 1 + getsolve (tail pls)