#include #include #include using namespace std; int main(){ int n,tmp; cin >> n; tmp = 0; vector v; for (int i = 0; i < n; i++) { int a; cin >> a; v.push_back(a); } //昇順、降順を作り比較 for (int i = 0; i < n - 2; i++) { vector org,down,up; org = {v[i],v[i+1],v[i+2]}; down = {v[i],v[i+1],v[i+2]}; up = {v[i],v[i+1],v[i+2]}; sort(down.begin(),down.end(),greater()); sort(up.begin(),up.end()); if (org != down && org != up) { tmp++; } } cout << tmp << "\n"; return 0; }