module AOJ_Volume0107;

import std.stdio,std.string,std.conv;

int main()
{
	int a[13];
	while(true)
	{
		int n = readln.chomp.to!int;
		if(n == 0) break;

		foreach(i;0..13) a[i] = 0;
		int res[];

		string[] s = readln.chomp.split(" ");
		foreach(i;0..n)
		{
			a[i] = s[i].to!int;
			res ~= a[i];
		}

		int count = 0;
		while(true)
		{
			int[int] m;

			foreach(i;0..n)
			{
				m[a[i]]++;
			}

			foreach(i;0..n)
			{
				a[i] = m[a[i]];
			}

			bool flag = true;
			foreach(i;0..n)
			{
				if(res[i] != a[i]) flag = false;
			}

			if(flag)
			{
				count.writeln;
				foreach(i;0..n)
				{
					if(i == n-1) a[i].writeln;
					else write(a[i]," ");
				}
				break;
			}
			else
			{
				foreach(i;0..n)
				{
					res[i] = a[i];
				}
				count++;
			}
		}
	}
	return 0;
}