#include<cstdio>
const int N=20+10;
int a[N],n,ans;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=2;i<n;i++)
		ans+=(a[i]>a[i-1]&&a[i]<a[i+1])||(a[i]<a[i-1]&&a[i]>a[i+1]);
	printf("%d",ans);
	return 0;
}
