#include "bits/stdc++.h" typedef long long int ll; using namespace std; int main() { ll towersCount = 0; vector heights; cin >> towersCount; ll tmp = 0; ll count = 0; for (int i = 0; i < towersCount; ++i) { cin >> tmp; heights.push_back(tmp); } for (ll i = 0; i < towersCount - 1; ++i) { for (ll j = i+1; j < towersCount ; ++j) { if(heights[i] < heights[j]) break; if(heights[i] == heights[j]) { if(i+1 == j) { break; } else { count+=(j-i)-1; break; } } } } cout << count << endl; return 0; }