#include<algorithm>
#include<iostream>
#include<map>

int n;
int a[12], prv[12];
std::map<int, int> cnt, tmp;
int ans;

int main()
{
	while( std::cin >> n, n )
	{
		ans = 0;
		memset( a, 0, sizeof( a ) );
		memset( prv, 0, sizeof( prv ) );
		cnt.clear();
		tmp.clear();

		for( int i = 0; i != n; ++i )
		{
			std::cin >> a[i];
			++cnt[a[i]];
		}

		while( true )
		{
			std::copy( a, a + 12, prv );

			for( int i = 0; i != n; ++i )
			{
				a[i] = cnt[a[i]];
				++tmp[a[i]];
			}

			if( std::equal( a, a + 12, prv ) )
				break;

			++ans;

			cnt = tmp;
			tmp.clear();
		}

		std::cout << ans << std::endl;
		for( int i = 0; i != n; ++i )
			std::cout << a[i] << ( i == n - 1 ? '\n' : ' ' );
	}

	return 0;
}