import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] a = new int[n]; int ans = 0; for(int i = 0 ; i < n ; i++) a[i] = sc.nextInt(); for(int i = 1 ; i < n - 1 ; i++) { int[] x = {a[i - 1], a[i], a[i + 1]}; if(x[0] != x[1] && x[1] != x[2] && x[2] != x[0]) { Arrays.sort(x); if(a[i] == x[0] || a[i] == x[2]) { ans++; } } } System.out.println(ans); } }