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

void main()
{
	int n;
	while (n = readln.chomp.to!int, n) {
		auto p = readln.chomp.split.map!(to!int).array;
		auto x = new int[](p.length);
		x[] = -1;
		int cnt;
		while (1) {
			foreach (i; 0..x.length) {
				x[i] = p.count!(a => a == p[i]);
			}
			if (x == p) break;
			p = x.dup;
			cnt++;
		}
		cnt.writeln;
		x.map!(to!string).join(" ").writeln;
	}
}