N = gets.chomp.to_i
numArr = gets.chomp.split(" ").map(&:to_i)


key = 1
arr = numArr.select{ |num|
    if(num == key)
        key += 1
    end
}

if(arr.size.zero?)
    puts -1
else
    puts numArr.size - arr.size
end
