'use strict';

function Main(input) {
    input = input.split("\n");
    const B = input[1].split(" ").map((n) => parseInt(n, 10));
    let tc = B.concat().sort();
    if (tc[0] != 1) {
        console.log(-1);
        return 0;
    }

    function ins(list, e) {
        let temp = list.concat();
        temp.splice(e - 1, 0, e);
        return temp;
    }

    function array_equal(a, b) {
        if (!Array.isArray(a))    return false;
        if (!Array.isArray(b))    return false;
        if (a.length != b.length) return false;
        for (var i = 0, n = a.length; i < n; ++i) {
            if (a[i] !== b[i]) return false;
        }
        return true;
    }

    tc.shift();
    let before = [{list: [1], candidate: tc, output:[1]}];
    for (let i = 2; i <= B.length; i++) {

        let temp = [];
        for (let elem of before) {
            for (let j = 1; j <= i; j++) {
                const index = elem.candidate.findIndex(v => v === j);
                if (index!==-1) {
                    let t = elem.candidate.concat();
                    t.splice(index, 1);

                    temp.push({
                        list: ins(elem.list, j),
                        candidate: t,
                        output: elem.output.concat(j)
                    })
                }
            }
        }

        before = temp;
    }
    var elem = before.find(e => array_equal(e.list, B));
    if (elem) {
        for (let s of elem.output) {
            console.log(s);
        }
    }else {
        console.log(-1);
    }
    return 0;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));