function Main(input) {
    var N = parseInt(input[0], 10);
    var a = input.slice(1).map(w => parseInt(w, 10));

    var block = 0;
    var num = 1;

    for (var i = 0; i < N; i++) {
        if (a[i] === num) {
            num++;
        } else {
            block++;
        }
    }

    console.log(num === 1 ? -1 : block);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n|\s/));