#include #include int x[200010]; std::set< std::pair > S; int main() { int ans = 0; int a; scanf("%d",&a); for(int i=1;i<=a;i++) scanf("%d",&x[i]); for(int i=2;i<=a-1;i++) S.insert(std::make_pair(x[i],i)); while(!S.empty()) { std::set< std::pair > ::iterator it = S.end(); it--; int ind = (it->second); S.erase(it); if(x[ind-1]x[ind+1]) { ans++; x[ind] = (x[ind-1]