package main import ( "fmt" "math" "sort" ) func MaxInt(x ...int) int { ret := x[0] for i := 1; i < len(x); i++ { ret = int(math.Max(float64(ret), float64(x[i]))) } return ret } func MinInt(x ...int) int { ret := x[0] for i := 1; i < len(x); i++ { ret = int(math.Min(float64(ret), float64(x[i]))) } return ret } func AbsInt(x int) int { return int(math.Abs(float64(x))) } func SortInt(x ...int) { sort.Sort(sort.IntSlice(x)) } func SortReverseInt(x ...int) { sort.Sort(sort.Reverse(sort.IntSlice(x))) } func resolve(N int, A []int) int { cnt := 0 for i := 1; i < N-1; i++ { if A[i-1] == A[i] || A[i] == A[i+1] || A[i-1] == A[i+1] { continue } a := make([]int, 3) copy(a, A[i-1:i+2]) SortInt(a...) if a[1] == A[i] { continue } cnt += 1 } return cnt } func main() { var N int fmt.Scanf("%d\n", &N) A := make([]int, N) for i := 0; i < N; i++ { fmt.Scanf("%d", &A[i]) } fmt.Println(resolve(N, A)) }