#include<bits/stdc++.h>
using namespace std;
int n,a[100],ans;
int main(){
	cin>>n;
	for (int i=0;i<n;i++) cin>>a[i];
	for (int i=0;i<n-2;i++)
		if (a[i]<a[i+1]&&a[i+1]<a[i+2])
			ans++;
		else if (a[i]>a[i+1]&&a[i+1]>a[i+2])
			ans++;
	cout<<ans<<endl;
	return 0;
}