n = gets.chomp.to_i
a = gets.split(" ")
a.map!{|item| item.to_i}
cnt = 0
j = 1
for i in 0..(n-1)
    if a[i] == j
        j += 1
        cnt += 1
    end
end
if cnt == 0
    puts -1
else
    puts n-cnt
end