#include #define EM 1000000 using namespace std; using LL = long long; using P = pair; LL LINF = 1e18; int INF = 1e9; LL mod = 1e9+7; using vint = vector; using vLL = vector; using vvint = vector>; using vvLL = vector>; template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } int main(){ int N; cin >> N; vector a(N); for(int i = 0; i < N;i++) cin >> a[i]; int tar = N; for(int i = N-1;i >= 0;i--){ if(a[i] == tar) tar--; } int ans = N-(N-tar); cout << ans << endl; }