#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
	int N,a;
	cin>>N;
	int tmp=0;
	for(int i=0;i<N;i++){
		cin>>a;
		if(a==tmp+1){
			tmp++;
		}
	}
	
	if(tmp!=0)cout<<N-tmp<<endl;
	else cout<<-1<<endl;
}