var count = 0;

function Main(input) {

	input = input.split("\n");
	
    var n = parseInt(input[0]);
    var p = input[1].split(" ");
    
    for(var i = 0;i < n-3;i++){
        if(p[i]<p[i+1]<p[i+2]){
            count++
        }
    }
    
    console.log(count);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));