#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; int main() { int i, j, k; int n; vectora; cin >> n; for (i = 0; i < n; i++) { int num; cin >> num; a.push_back(num); } int cnt = 0; for (i = 0; i < n - 2; i++) { bool flag = false; if (a[i] == a[i + 1] || a[i] == a[i + 2]) continue; int num1, num2, num3; num1 = a[i]; num2 = a[i+1]; num3 = a[i+2]; int minn = min({ num1,num2,num3 }); int maxn = max({ num1,num2,num3 }); if (num2 == maxn || num2 == minn) { cnt++; } } cout << cnt << endl; getchar(); getchar(); return 0; }