#include <iostream>
using namespace std;
int main()
{
	int n, s[12], t[12], i, j, c;
	bool f;
	while (cin >> n, n)
	{
		for (i = 0; i < n; i++)
		{
			cin >> s[i];
		}
		c = 0;
		while (1)
		{
			f = false;
			for (i = 0; i < n; i++)
			{
				t[i] = 0;
				for (j = 0; j < n; j++)
				{
					if (s[i] == s[j])
						t[i]++;
				}
			}
			for (i = 0; i < n; i++)
			{
				if (s[i] != t[i])
				{
					for (j = 0; j < n; j++)
						s[j] = t[j];
					f = true;
					c++;
					break;
				}
			}
			if (!f)
			{
				cout << c << endl;
				for (i = 0; i < n; i++)
				{
					cout << t[i];
					if (i == n-1)
						cout << endl;
					else
						cout << " ";
				}
				break;
			}
		}
	}
}