#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main ( void )
{
	int n; // ツ青板療アツづ個陳キツつウ
	while ( cin >> n && n != 0 )
	{
		vector <int> S(n);
		for ( int i = 0; i < n; i++ )
			cin >> S[i];

		vector <int> V(n);
		vector <int> V_next(n);
		V = S;

		int cnt = 0;
		while ( 1 )
		{
			for ( int i = 0; i < n; i++ )
			{
				V_next[i] = count( V.begin(), V.end(), V[i] );
			}
			cnt++;

			if ( V == V_next )
			{
				cnt--;
				break;
			}

			V = V_next;

		}

		cout << cnt << endl;
		for ( int i = 0; i < n; i++ )
		{
			cout << V[i];
			if ( i < n-1 )
				cout << " ";
		}
		cout << endl;

	}

	return 0;
}