import java.util.Scanner; public class Main { public static void main(String[] args) { try { Scanner scan = new Scanner(System.in); int count = scan.nextInt(); int[] height = new int[count]; for (int i = 0; i < count; ++i) { height[i] = scan.nextInt(); } int ans = 0; for (int i = 1; i < count - 1; ++i) { int max = 0, min = 101; boolean flag = false; for (int j = -1; j < 2; ++j) { if (max == height[i + j] || min == height[i + j]) { flag = true; break; } if (max < height[i + j]) { max = height[i + j]; } if (min > height[i + j]) { min = height[i + j]; } } if (flag) { continue; } if (max != height[i - 1] && min != height[i - 1] || max != height[i + 1] && min != height[i + 1]) { ++ans; } } System.out.println(ans); scan.close(); } catch (Exception e) { e.printStackTrace(); } } }