n = gets.to_i
num = gets.chomp.split(" ").map(&:to_i)
count = 0
e = 0


n.times do 
   if num[e] == e+1
    e += 1
   else
    num.delete_at(e)
    count += 1
   end
end

if count >= n
  puts "-1"
  exit
end

puts count

