using System; using System.Collections.Generic; using System.Linq; public class Yuki116 { public static void Main() { var n = int.Parse(Console.ReadLine()); var a = Console.ReadLine() .Split(' ') .Select(x => int.Parse(x)) .ToList(); int ans = 0; for(int i = 0; i < n - 2; i++) { ans += Check(a[i], a[i + 1], a[i + 2]); } Console.WriteLine(ans); } public static int Check(int x, int y , int z) { if(x == y|| x == z || y == z) return 0; if(Math.Max(x , Math.Max(y , z)) == y || Math.Min(x , Math.Min(y , z)) == y) return 1; return 0; } }