N = gets.to_i
A = gets.split.map(&:to_i)

aa = A
r=[]
if !A.find_index(1)
  result = -1
else
  for i in 1..N
    if aa.find_index(i) != nil
      aa.shift(aa.find_index(i)+1)
      r.push(i)
    else
      break
    end
  end
  result = N - r.size
end
puts result