unittest
{
	assert( [ "3", "1 2 1" ].parse.expand.solve == "1\n1\n2" );
	assert( [ "2", "2 2" ].parse.expand.solve == "-1" );
	assert( [ "9", "1 1 1 2 2 1 2 3 2" ].parse.expand.solve == "1\n2\n2\n3\n1\n2\n2\n1\n1" );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	input.popFront;
	auto bs = input.front.split.to!( long[] );
	return tuple( bs );
}

auto solve( long[] bs )
{
	// 操作を逆順にして、全部揃っている状態から削除する場合を考える
	auto anss = new long[]( bs.length );
	LOOP: foreach_reverse( ref ans; anss )
	{
		foreach_reverse( j; 0 .. bs.length )
		{
			if( bs[ j ] != j + 1 ) continue;
			ans = bs[ j ];
			bs = bs[ 0 .. j ] ~ bs[ j + 1 .. $ ];
			continue LOOP;
		}
		return "-1";
	}
	return anss.to!( string[] ).join( "\n" );
}
