← Home
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

func main() {
	data, _ := io.ReadAll(os.Stdin)
	pos := 0
	nextInt := func() int64 {
		for pos < len(data) && (data[pos] < '0' || data[pos] > '9') {
			pos++
		}
		var v int64
		for pos < len(data) && data[pos] >= '0' && data[pos] <= '9' {
			v = v*10 + int64(data[pos]-'0')
			pos++
		}
		return v
	}

	n := int(nextInt())
	var mex int64 = 0
	ans := -1

	for i := 1; i <= n; i++ {
		x := nextInt()
		if ans == -1 {
			if x > mex {
				ans = i
			} else if x == mex {
				mex++
			}
		}
	}

	out := bufio.NewWriter(os.Stdout)
	fmt.Fprint(out, ans)
	out.Flush()
}