n = gets.to_i
a = gets.split.map(&:to_i)

breaks = 0
target = 1

a.each.with_index do |num, i|
  if i - breaks + 1 == num && num == target
    target += 1
  else
    breaks += 1
  end
end

puts target != 1 ? breaks : -1