#include <bits/stdc++.h>
using namespace std;
const int N = 1001;
int n, a[N], sum;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    if (i == 0 || i == 1) continue;
    if (a[i - 1] > a[i - 2] && a[i - 1] > a[i] ||
        a[i - 1] < a[i - 2] && a[i - 1] < a[i])
      sum++;
  }
  printf("%d", sum);
  return 0;
}
