function Main(input){
var row = input.split("\n")[1].split(" ");
var count = 0;
for(i=0;i<=(row.length-2);i++){
  var a = new Number(row[i-1])<new Number(row[i]);
  var b = new Number(row[i])<new Number(row[i+1]);
  var c = new Number(row[i-1])>new Number(row[i]);
  var d = new Number(row[i])>new Number(row[i+1]);
  if(a===true&&b===true ||
     c===true&&d===true){
       count +=1;
     }
}
console.log(count);
}
  Main(require('fs').readFileSync('/dev/stdin','utf8'));