#include <iostream>
using namespace std;

int main()
{
    int N,counter=0;
    bool high;
    bool low;
    int h[3000];
    cin >> N;
    for(int i =1; i<=N; i++)
    {
        cin >> h[i];
        if(h[i]>h[i+1] and h[i]>h[i-1])
        {
             high=true;
        }
        else
        {
            if(h[i]<h[i+1] and h[i]<h[i-1])
            {
                 low=true;
            }
        }
        if( low==true or  high==true)
        {
            counter++;
        }
    }
    cout << counter;



    return 0;
}
