#include #include #define rep(i,a) for(int i=0;i<(a);++i) const int MAX_N = 100; int N, A[MAX_N]; int ans; int main() { scanf( "%d", &N ); rep( i, N ) { scanf( "%d", A+i ); if( i >= 2 && A[i-2] != A[i-1] && A[i-1] != A[i] ) { int mi = std::min( A[i-2], std::min( A[i-1], A[i] ) ); if( A[i-2] == mi || A[i] == mi ) ++ans; } } printf( "%d\n", ans ); return 0; }