main = do
 getLine
 pList <- map read . words <$> getLine :: IO[Int]
 print $ sum $ map (\(a,b,c) -> if (((a < b) && (b < c)) || ((c < b) && (b < a))) then 1 else 0) $ zip3 pList (drop 1 pList) (drop 2 pList)