#include <iostream> using namespace std; bool func(int a, int b, int c) { bool ok = true; if (a == b || b == c || c == a) ok = false; int nmax = max(a, max(b, c)), nmin = min(a, min(b, c)); if (b != nmax && b != nmin) ok = false; return ok; } int main(void) { int n, a, b, c, tmp; cin >> n >> a >> b >> c; int ans = 0; if (func(a, b, c)) ++ans; for (int i = 3; i < n; ++i) { cin >> tmp; a = b, b = c, c = tmp; if (func(a, b, c)) ++ans; } cout << ans << endl; return 0; }