#include<iostream>
using namespace std;
#define mod 1e9+7
int main()
{
	int a[25];
	int n, sum = 0;
	cin >> n;
	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]) || (a[i] < a[i - 1] && a[i] > a[i + 1]))sum++;
	cout << sum;
}