#include #define rep(i, ss, ee) for (int i = ss; i < ee; ++i) using namespace std; inline bool isK(const int &a, const int &b, const int &c) { if (a == b or a == c or b == c) return 0; if ((a > b && c > b) or (a < b && c < b)) return 1; return 0; } int main() { cin.tie(0); ios::sync_with_stdio(false); int N, ans = 0; cin >> N; vector v(N); rep(i, 0, N) { cin >> v[i]; } rep(i, 0, N - 2) { if (isK(v[i], v[i + 1], v[i + 2])) ans++; } cout << ans << endl; getchar(); }