read N;read -a a;resultFlag=1;j=0;for i in ${a[@]};do  if [ ${a[$j]} = $resultFlag ]; then let resultFlag++;fi; let j++ ;done; if [ "$resultFlag" = "1" ];then echo "-1";else echo $((N-resultFlag + 1));fi