#include "bits/stdc++.h"
using namespace std;

int main() {
	int N, P[20], ANS = 0;
	cin >> N;
	for (int i = 0; i < N; i++) cin >> P[i];
	for (int i = 0; i < N - 2; i++) {
		if ((P[i + 1] - P[i]) * (P[i + 2] - P[i + 1]) > 0) ANS++;
	}
	cout << ANS;
}