inp = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n')
N = inp.shift() * 1
a = inp.shift().split(' ').map(x => x - 0)
i = 1
c = 0
for (j=0;j<N;j++) {
    if (a[j] == i) {
        i++
    } else {
        c++
    }
}
console.log(c == N ? -1 : c) 