Imports System

Public Class Program

    Public Shared Sub Main(args As String())

        Dim N As Integer = Integer.Parse(Console.ReadLine)
        Dim a() As Integer = Array.ConvertAll(Of String, Integer)(Console.ReadLine.Split(" "), AddressOf Integer.Parse)


        Dim nextnumber As Integer = 1

        Dim breaknumber As Integer = 0

        Dim OK As Boolean = False


        For i As Integer = 0 To a.Length - 1

            If a(i) = 1 Then
                OK = True
            End If

            If a(i) = nextnumber Then
                nextnumber += 1
            Else
                breaknumber += 1

            End If

        Next


        If OK Then
            Console.WriteLine(breaknumber)
        Else
            Console.WriteLine(-1)
        End If





    End Sub




End Class
