#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[300000];
int main(){
	ll n;
	cin>>n;
	ll i,j=1;
	for(i=0;i<n;i++){
		cin>>a[i];
		if(a[i]==j)
			j++;
	}
	if(j==1)
		cout<<"-1";
	else{
		cout<<n-j+1;
	}
} 