#include using namespace std; #ifdef LOCAL_DEBUG #include "LOCAL_DEBUG.hpp" #endif #define int long long signed main(){ int n; cin >> n; vector> a(n); for(int i = 0; i < n; i++){ cin >> a[i].first; a[i].second = i; } sort(a.rbegin(),a.rend()); int ans = 0, left = a[0].second; for(auto p : a){ if(left < p.second){ ans++; }else{ left = p.second; } } cout << ans << endl; return 0; }