Module Module1

    Sub Main()

        Dim N As Integer = CInt(Console.ReadLine())
        Dim tmp As String() = Split(Console.ReadLine(), " ")

        Dim c As Integer = 1
        Dim k As Integer = 0
        For ix As Integer = 0 To N - 1
            If tmp(ix) = c Then
                c += 1
            Else
                k += 1
            End If
        Next

        If c > 1 Then
            Console.WriteLine(k)
        Else
            Console.WriteLine(-1)
        End If
        'Console.ReadLine()

    End Sub

End Module
