main :: IO ()
main = do
    n <- read <$> getLine :: IO Int
    ps <- map read.words <$> getLine :: IO [Int]
    print $ length $ filter id $ zipWith3 (\a b c->(a<b&&b<c) ||(a>b&&b>c)) ps (tail ps) $ (tail.tail) ps
