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

ret = 0

target = 1
i = 0
while i < A.length
  if A[i] == target
    target += 1
  else
    ret += 1
  end
  i += 1
end

if target == 1
  ret = -1
end

p ret
