#include #include #include #include #include #include #include #include #define FOR(i, a, b) for(int i=(a);i<=(b);i++) #define RFOR(i, a, b) for(int i=(a);i>=(b);i--) #define MOD 1000000007 using namespace std; int main(void) { int n; int a[101]; int count = 0; cin >> n; FOR(i, 1, n) { cin >> a[i]; } FOR(i, 1, n - 2) { if (!((a[i] < a[i + 1]) && (a[i + 1] < a[i + 2]))) { if ((a[i + 2] - a[i + 1] != 0) && (a[i + 1] - a[i] != 0) && (a[i + 2] - a[i] != 0)) { count++; } } } cout << count << endl; return 0; }