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