#include <iostream>
#include <string>
using namespace std;

int main()
{

	int n, cnt, flg;
	int s[12], cs[12];

	while (cin >> n)
	{
		if (n == 0) break;
		cnt = 0;
		flg = 1;

		for (int i = 0; i < n; i++)
		{
			cin >> s[i];
		}

		for (int i = 0; i < 12; i++)
		{
			cs[i] = 0;
		}

		while (1)
		{
			flg = 0;
			for (int i = 0; i < n; i++)
			{
				for (int j = 0; j < n; j++)
				{
					if (s[i] == s[j])       // cs[i] = s[i]???????????????
					{
						cs[i]++;
					}
				}
			}
			cnt++;
			for (int i = 0; i < n; i++)
			{
				if (s[i] != cs[i])        // s = cs ?????????????????¨??????cs?????????????????°???P
				{
					flg++;
				}
			}
			if (flg==0)
			{
				cnt--;
				break;
			}
			else
			{
				for (int i = 0; i < n; i++)
				{
					s[i] = cs[i];
					cs[i] = 0;
				}
			}
		}
		
		cout << cnt << endl;
		for (int i = 0; i < n-1; i++)
		{
			cout << cs[i] << " ";
		}
		cout << cs[n-1] << endl;
	}

	return 0;
}