#include #include #include using namespace std; #define REP(i,n) for (int i=0;i<(n);i++) #define SWAP(a,b) (a ^= b,b = a ^ b,a ^= b) int main() { int N, a[101], b[3], ans = 0; cin >> N; REP(i, N) cin >> a[i]; REP(i, N - 2) { REP(j, 3) b[j] = a[i + j]; if (b[0] == b[1] || b[1] == b[2] || b[0] == b[2]) continue; if (b[1] > b[2]) SWAP(b[1], b[2]); if (b[0] > b[1]) SWAP(b[0], b[1]); if (b[1] > b[2]) SWAP(b[1], b[2]); if (b[1] != a[i + 1]) ans++; } cout << ans << endl; return 0; }