fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val d = readLine()!!.split(" ").map { it.toInt() }

    (1..d.lastIndex-1).count { (d[it]-d[it-1])*(d[it]-d[it+1])<0 }
        .let { println(it) }

}