import std.stdio, std.conv, std.string, std.range, std.math, std.algorithm; void main() { auto N = readln.strip.to!int; auto A = readln.split.to!(int[]); iota(2, A.length) .count!(i=>A[i-2]A[i]&&A[i-2]!=A[i] ||A[i-2]>A[i-1]&&A[i-1]