package m.shin; import java.util.Scanner; public class Con116 { public static void main(String[] args) { Scanner s = new Scanner(System.in); int N = s.nextInt(); int[] A = new int[N]; for(int i = 0;i < N;i++){ A[i] = s.nextInt(); } s.close(); int count = 0; for(int i = 0;i < N -2;i++){ if((A[i] - A[i+1]) * (A[i+2] - A[i+1]) > 0 && A[i] != A[i+2]){ count++; } } System.out.println(count); } }