using System; using System.Linq; class Program { static void Main() { int n = int.Parse(Console.ReadLine()); int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray(); int cnt = 0; for (int i = 0; i < n - 2; i++) { int[] c = { a[i], a[i + 1], a[i + 2] }; if (c[0] == c[1] || c[0] == c[2] || c[1] == c[2]) continue; if (c[1] == c.Max() || c[1] == c.Min()) cnt++; } Console.WriteLine(cnt); } }