#include <iostream>
#include <vector>
#include <map>

using namespace std;

void solve()
{
	int n;
	while(cin >> n, n)
	{
		vector<int> Vec(n);
		for(int i = 0; i < n; ++i)
		{
			cin >> Vec[i];
		}
		
		bool flag = true;
		int count = 0;
		while(flag)
		{
			map<int, int> Map;
			for(int i = 0; i < n; ++i)
			{
				Map[Vec[i]]++;
			}
			vector<int> Vec_buf(n);
			for(int i = 0; i < n; ++i)
			{
				for(map<int, int>::iterator Ite = Map.begin(); Ite != Map.end(); ++Ite)
				{
					if((*Ite).first == Vec[i])
					{
						Vec_buf[i] = (*Ite).second;
					}
				}
			}
			if(Vec == Vec_buf)
			{
				flag = false;
			}
			Vec = Vec_buf;
			count++;
		}
		count--;
		cout << count << endl;
		for(int i = 0; i < n - 1; ++i)
		{
			cout << Vec[i] << " ";
		}
		cout << Vec[n - 1] << endl;
	}
}

int main()
{
	solve();
	return(0);
}