#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	vector <int> v(n);
	for(auto &x:v) cin>>x;
	int ans=0,j=1;
	for(int i=0;i<n;i++)
	{
		if(v[i]==j) j++;
		else ans++;
	}
	if(ans==n) cout<<"-1"<<endl;
	else cout<<ans<<endl;
}