const val MOD: Long = (1e9+7).toLong()

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    /* val b = ArrayList(readLine()!!.split(' ').map{it.toInt()-1}) */
    val b = arrayListOf(*readLine()!!.split(' ').map{it.toInt()-1}.toTypedArray())

    val l = arrayListOf(0)
    l.removeAt(0)
    /* val l: ArrayList<Int> = arrayListOf() */
    while (b.size > 1) {
        var f = false
        for ((i, x) in b.withIndex().reversed()) {
            if (i == 0) continue
            if (i == x) {
                l.add(x+1)
                b.removeAt(i)
                f = true
                break
            }
        }

        if (!f) {
            if (b[0] == 0) {
                l.add(1)
                b.removeAt(0)
                continue
            }

            println(-1)
            return
        }
    }
    if (b[0] != 0) {
        println(-1)
        return
    } else {
        println(1)
        for (x in l.reversed()) {
            println(x)
        }
    }
}
