
clash::Int->[Int]->Int
clash n (x:xs) | null xs = if (n > 1) || (n == 1 && x == 1) then 0 else -1
               | n == x = clash (n+1) xs
               | otherwise = 1 + clash n xs

main = do
  getLine
  an <- map read . words <$> getLine
  print $ clash 1 an
