import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner input = new Scanner(System.in); int n = input.nextInt(); int[] arr = new int[n]; for (int i = 0; i < n; i++) arr[i] = input.nextInt(); int cnt = 0; if (n >= 3) { for (int i = 1; i < n - 1; i++) { if ((arr[i - 1] < arr[i] && arr[i] > arr[i + 1]) || (arr[i - 1] > arr[i] && arr[i] < arr[i + 1])) cnt++; } } System.out.println(cnt); } }
08-18