#include<stdio.h> #include<iostream> using namespace std; int main() { long long n,a,b,i,c; long long ar[1000]; while(cin>>n) { for(i=0; i<n; i++) { cin>>ar[i]; } c=0; for(i=0; i<n; i++) { //cout<<ar[i]<<endl; if(i>0&&i<n-1) { if((ar[i]>ar[i-1]&&ar[i]>ar[i+1])||((ar[i]<ar[i-1]&&ar[i]<ar[i+1]))) { c++; //cout<<ar[i]<<" "<<ar[i+1]<<" "<<ar[i-1]<<" "<<i<<endl; } } } cout<<c<<endl; } return 0; }