import Control.Applicative
import Control.Monad
import Data.List

main = do
  n <- (read::String -> Int) <$> getLine
  arr <- map (read::String -> Int) . words <$> getLine
  print $ foldl (
    \acc i -> if ((arr !! i) - (arr !! (i + 1))) * ((arr !! (i + 2)) - (arr !! (i + 1))) < 0 
      then acc + 1 
      else acc
      ) 0 [0..(n - 3)]