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

if !(ary.include?(1))
    puts -1
    exit
end

count = 0
i= 0
j = 1
while i < ary.length && j <= ary.length do
    if ary[i] != j  
        count += 1
        i += 1
    else
        i += 1
        j += 1
    end
end

puts count