#include<cstdio>
using namespace std;
int n,cnt,now;
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;++i)
	{
		scanf("%d",&now);
		if (now==cnt+1)
			++cnt;
	}
	if (cnt)
		printf("%d",n-cnt);
	else
		puts("-1");
	return 0;
}