#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>

using namespace std;

int n;

int main()
{
  // freopen("da.in", "r", stdin);
  // freopen("da.out", "w", stdout);
   scanf("%d", &n);
   if (n < 3){
      printf("0");
      return 0;
   }
   int x, y, z, nr = 0;
   scanf("%d %d ", &x, &y);
   for (int i = 3; i <= n; ++i){
      scanf("%d", &z);
      if (x < y && y > z)
         ++nr;
      x = y;
      y = z;
   }
   printf("%d", nr);

   return 0;
}