function Main(input) {
    input = input.split("\n");
    
    var n = Number(input[0]);
    var rengaArr = input[1].split(" ");
    
    var res = 0;
    var ord = 1;
    for(var i=0; i<n; i++){
        if(Number(rengaArr[i])==ord){
            ord++;
        }else{
            res++;
        }
    }
    if(ord == 1){
        console.log(-1);
    }else{
        console.log(res);
    }
    
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));