#include <iostream>
using namespace std;

int main(){
 int n;
 int a[2][12];
 int flg,work,i,j,cnt;
 
 while(1){
	cin>>n;
	if(n==0){break;}
	flg=0;
	for(i=0;i<n;i++){cin>>a[flg][i];}
	cnt=-1;
	
	do{
	 work=0;
	 for(i=0;i<n;i++){
	  a[1-flg][i]=0;
	  for(j=0;j<n;j++){
		 if(a[flg][i]==a[flg][j]){a[1-flg][i]++;}
	  }
	  if(a[flg][i]==a[1-flg][i]){work++;}
	 }
	  
	 flg=1-flg;cnt++;
	}while(work!=n);
	
	cout<<cnt<<endl;
	for(i=0;i<n;i++){
	 if(i){cout<<" ";}
	 cout<<a[flg][i];
	}
	cout<<endl;
 }
 
 return 0;
}