let n = Scanf.scanf " %d" (+) 0
let ps = Array.init n @@ fun _ -> Scanf.scanf " %d" (+) 0
let ans = ref 0
let _ = for i = 0 to n - 3 do if ps.(i) < ps.(i + 1) && ps.(i + 1) < ps.(i + 2) || ps.(i) > ps.(i + 1) && ps.(i + 1) > ps.(i + 2) then incr ans done;
  Printf.printf "%d\n" !ans