#include<stdio.h>
#include<vector>
#include<algorithm>
int main()
{
	int n,i,j,s,r;
	while(scanf("%d",&n),n)
	{
		std::vector<int>v[2];
		v[0].resize(n);v[1].resize(n);
		for(s=r=i=0;i<n;++i)scanf("%d",&v[0][i]);
		for(;;)
		{
			for(i=0;i<n;++i)v[!s][i]=std::count(v[s].begin(),v[s].end(),v[s][i]);
			if(v[!s]==v[s])break;
			++r;
			s=!s;
		}
		printf("%d\n",r);
		for(i=0;i<n;++i)printf("%d%c",v[0][i],i+1-n?' ':'\n');
	}
	return 0;
}