#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	int n,sum=0;
	cin >> n;
	long long a[21];
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 1; i < n - 1; i++)
	{
		if (a[i] > a[i - 1] && a[i] < a[i + 1]) sum++;
		else if (a[i] < a[i - 1] && a[i] > a[i + 1]) sum++;
	}
	cout << sum << endl;
}