import Data.List (zipWith3)

main = do
  getLine
  li <- getLine
  let ps = map read $ words li
  let answer = compute ps
  print answer

compute :: [Int] -> Int
compute ps = length $ filter id $ zipWith3 prop ps (tail ps) (drop 2 ps)

prop a b c = a < b && b < c || a > b && b > c
