#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, s[1100], mn = -1, mx = -1, ans = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> s[i];
  for (int i = 2; i < n; i++) {
    if (s[i - 1] > s[i] && s[i + 1] > s[i]) {
      if (mx == -1) {
        ans++;
      }
    }
  }
  for (int i = 2; i < n; i++) {
    if (s[i - 1] < s[i] && s[i + 1] < s[i]) {
      ans++;
    }
  }
  cout << ans;
}
