let () = Scanf.scanf "%d\n" @@ fun n ->
  let ps = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun p -> p in
  Printf.printf "%d\n" @@
  List.length @@
  List.filter (fun b -> b) @@
  Array.to_list @@
  Array.init (n - 2) @@ fun i ->
    let ps' = [| ps.(i); ps.(i + 1); ps.(i + 2) |] in
    Array.sort compare ps';
    ps'.(1) = ps.(i + 1)