#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 cnt = 0, res = a[0].second; for(auto p : a){ if(res >= p.second){ cnt++; res = p.second; }else{ break; } } cout << n - cnt << endl; return 0; }