#include<stdio.h>

int main(){
	int n,i,j;
	int ar[12];
	int old_ar[12];
	int t;
	while(1){
	scanf("%d",&n);
		if(n==0)return 0;
	for(i=0;i<n;i++){
		scanf("%d",&ar[i]);
		old_ar[i]=ar[i];
	}
	t=0;
	int c;
	while(1){
		t++;
		for(i=0;i<n;i++){
			c=0;
			for(j=0;j<n;j++)if(old_ar[i]==old_ar[j])c++;
			ar[i]=c;
		}
		for(i=0;i<n;i++)if(ar[i]!=old_ar[i])break;
		if(i==n)break;
		for(i=0;i<n;i++)old_ar[i]=ar[i];
	}
	printf("%d\n",t-1);
	for(i=0;i<n;i++)printf("%d%c",ar[i],i==n-1?'\n':' ');
	}
}
	