
import Foundation

func main(){
   let n = Int(readLine()!)!
   let array = readLine()!.split(separator: " ")

   var j = 1
   var answer = 0
   for i in 0..<n {
      let curInt = Int(array[i])!
      if curInt == j {
         j += 1
      } else {
         answer += 1
      }
   }
   print(answer == n ? -1 :answer)
}
main()