n = gets.chomp.to_i
as = gets.chomp.split(" ").map(&:to_i);

result = 0
counter = 1

as.each do |a|
  if a == counter
    counter += 1
  else
    result += 1
  end
end

if n == result
  puts "-1"
else
puts result
end