using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace foryuki { class Program { static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); var a = ConvertStringArrayToIntArray(Console.ReadLine().Split()); int cnt = 0; for (int i = 0; i < n - 2; i++) { if (a[i] == a[i + 1] || a[i] == a[i + 2] || a[i + 1] == a[i + 2]) { continue; } if (a[i] < a[i + 1] && a[i + 1] < a[i + 2]) { continue; } if (a[i] > a[i + 1] && a[i + 1] > a[i + 2]) { continue; } cnt++; } Console.WriteLine(cnt); } //------------------------------------------------------------- static int[] ConvertStringArrayToIntArray(string[] array) { return Array.ConvertAll(array, str => int.Parse(str)); } static List ConvertStringArrayToIntList(string[] str) { var list = new List(); foreach (var c in str) list.Add(int.Parse(c)); return list; } } }