import strutils, sequtils let N, A = stdin.readLine.split.map parseInt var cnt = 0 for i in 1 ..< A.high: if (A[i] - A[i- 1]) * (A[i] - A[i + 1]) > 0: if A[i- 1] != A[i + 1]: cnt += 1 echo cnt