#include #include #include #include #include #include #include using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep2(i, d, n) for (int i = d; i < (int)(n); i++) #define rRep(i,n) for(int i = n; i >= 0; i--) #define rRep2(i,d,n) for(int i = n; i >= d; i--) #define forEach(arr) for (auto& it:arr) int main(void){ int n,c = 0; cin >> n; int bamboo[n]; rep(i,n){ cin >> bamboo[i]; } rep2(i,1,n - 1){ int l = bamboo[i-1],m = bamboo[i],r = bamboo[i+1]; int mi = min({l,m,r}); int ma = max({l,m,r}); if(l == m || l == r || m == r)continue; if(mi == m || m == ma) { c++; } else continue; } cout << c; }