var lines = [];
var N; var max = 0; var b = []; var flag = false;
var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
});

rl.on('close', function () {
    N = Number(lines[0]);
    b = lines[1].split(" ").map(value => Number(value));

    for (var i = 0; i < b.length; i++) {
        max = Math.max(max, b[i]);
    }

    dfs(1, [1]);
    if (flag === false) { console.log(-1); }

});

function dfs(n, comb) {
    if (n === N) { calc(comb); }
    else {
        if (1 < comb[n - 1] || flag === false) {
            comb[n] = 1; dfs(n + 1, comb);
        }
        if (flag === false) {
            comb[n] = comb[n - 1]; dfs(n + 1, comb)
        }

        if (comb[n - 1] < max || flag === false) {
            comb[n] = comb[n - 1] + 1; dfs(n + 1, comb)
        }
    }
    return (0);
}

function calc(comb) {
    var x = [1];

    for (var i = 1; i < N; i++) {
        if (comb[i] < comb[i - 1]) { x.unshift(1); }
        else { x.splice(comb[i] - 1, 0, comb[i]); }
    }


    if (x.join("") === b.join("")) {
        flag = true;
        for (var i = 0; i < N; i++) {
            console.log(comb[i]);
        }
    }
    return (0);
}