#include #define FOR(i,a,b) for(int i = (a); i < (b); ++i) #define REP(i,n) FOR(i,0,n) #define sz(n) (int)(n).size() using namespace std; typedef long long ll; int main() { int n, a[101]; cin >> n; int ans = 0; REP(i, n) cin >> a[i]; FOR(i, 2, n + 1) { if (a[i - 2] != a[i] && (a[i - 2] < a[i - 1] && a[i - 1]> a[i] || a[i - 2] > a[i - 1] && a[i - 1] < a[i])) ans++; } cout << ans << endl; return 0; }