#include <iostream>
using namespace std;
const int N = 1010;
int q[N];
int n;
bool isCheck(int u,int v){
if(u * v < 0) return false;
return true;
}
int main(){
cin >> n;
for(int i = 1;i <= n;i++) cin >> q[i];
if(n == 2){
cout << 0 << endl;
return 0;
}
int t = q[2] - q[1],res = 0;
for(int i = 3;i <= n;i++){
int u = q[i] - q[i - 1];
if(!isCheck(t,u)) res++;
t = u;
}
cout << res << endl;
return 0;
}