object Main extends App {
  var get = readInt
  var list = readLine.split(" ").map(_.toInt)
  var sum = 0
  for(i <-0 to get-3){
    if(list(i+1)>list(i) && list(i+1)<list(i+2))
        sum = sum + 1
    if(list(i+1)<list(i) && list(i+1)>list(i+2))
       sum = sum + 1
  }
  println(sum)
}