#include #include #include using namespace std; using ll = long long; int main(){ int n; cin >> n; vector a(n); for(auto &x: a) cin >> x; int ans = n; for(int i=n-1;i >= 0;i--){ if(ans == a[i]){ ans--; } } cout << ans << endl; return 0; }