#include <iostream>
using namespace std;
int a[25];
int main()
{
	int n,m=0;
	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])||(a[i]>a[i+1]&&a[i+1]>a[i+2])) m++;
	}
	cout << m << '\n';
}