#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,x,last,yue=0;
	bool f=false; 
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>x;
		if(i>=2){
			if(x<last){
				f=true;
			}if(x>last&&f==true){
				yue++;
				f=false;
			}
		}
		last=x;
	} 
	cout<<yue;
	return 0;
}

