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