import std.algorithm;
import std.array;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int [] solve (int n, int [] a)
{
	int [] res;
main_loop:
	while (a.length > 0)
	{
		foreach_reverse (i, c; a)
		{
			if (c == i + 1)
			{
				res ~= c;
				a = a[0..i] ~ a[i + 1..$];
				continue main_loop;
			}
		}
		return [-1];
	}
	reverse (res);
	return res;
}

void main ()
{
	int n;
	while (readf (" %s", &n) > 0)
	{
		readln;
		auto a = readln.splitter.map !(to !(int)).array;
		writefln ("%(%s\n%)", solve (n, a));
	}
}
