let () =
  Scanf.scanf "%d" @@ fun n ->
  let a = Array.init n (fun _ -> Scanf.scanf " %d" ((+) 0)) in
  Array.init (n-2) (fun i -> a.(i), a.(i+1), a.(i+2))
  |> Array.fold_left (fun v (x,y,z) -> if (x < y && y < z) || (x > y && y > z) then v+1 else v) 0
  |> Printf.printf "%d\n"

