#include <iostream>
using namespace std;

int main()
{
	int N;
	cin >> N;
	int c = 0;
	int w = 1;
	for(int n=0; n<N; n++){
		int a;
		cin >> a;
		if(a == w){
			w++;
		} else {
			c++;
		}
	}
	if(c == N){
		cout << -1;
	} else {
		cout << c;
	}
}
