import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

int[101] BS;

void main()
{
    auto N = readln.chomp.to!int;
    auto bs = readln.split.to!(int[]);

    foreach (b; bs) ++BS[b];

    int[] solve(int i, int[] as) {
        if (i == N+1) {
            if (as == bs) {
                return [];
            } else {
                return [-1];
            }
        }
        foreach (j; 1..i+1) if (BS[j]) {
            --BS[j];
            auto r = solve(i+1, as[0..j-1] ~ j ~ as[j-1..$]);
            if (r.empty || r[$-1] != -1) return [j] ~ r;
            ++BS[j];
        }
        return [-1];
    }

    foreach (r; solve(1, [])) writeln(r);
}