import java.util.Scanner; public class Test { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(), cnt = 0, a, b, c; a = sc.nextInt(); b = sc.nextInt(); for (int i = 2; i < n; i++) { c = sc.nextInt(); if ((a - b) * (b - c) * (c - a) != 0 && (a - b) * (c - b) > 0) { cnt++; } a = b; b = c; } System.out.println(cnt); } }