#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
const int N = 1010;
int arr[N];
int n,res;
int main(){
cin >> n;
for(int i = 0; i < n; i++){
cin >> arr[i];
}
for(int i = 1; i < n - 1; i++)
if(arr[i] > arr[i - 1] && arr[i] > arr[i + 1] || arr[i] < arr[i - 1] && arr[i] < arr[i + 1])
res ++;
cout << res << endl;
return 0;
}