import java.util.Scanner; public class Run { public static void main (String arg[]) { Scanner scan = new Scanner(System.in); int N = scan.nextInt(); int tmp2 = scan.nextInt(); int tmp1 = scan.nextInt(); int A, count = 0; for (int i = 0; i < N - 2; i++) { A = scan.nextInt(); if (tmp2 != A) { if (tmp2 < tmp1) { if (tmp1 > A) count++; } else if (tmp2 > tmp1) { if (tmp1 < A) count++; } } tmp2 = tmp1; tmp1 = A; } System.out.println(count); } }