let n=Int(readLine()!)!
let arr=readLine()!.characters.split{$0==" "}.map{Int(String($0))!}

var i = 0
var b = 0
var f = 0
for i in 0..<n {
  if( arr[i] != i - b + 1 ) {
    b += 1
  } else {
    f += 1
  }
}

if( f == 0 ) {
  b = -1
}

print(b)
    