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

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