#include <iostream>
#include <cstring>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)

int main(void){
	int i,j,n,count,flg;
	int p[12],tmp[12];

	while(cin>>n && n){
		rep(i,n) cin>>p[i];
		for(count=0;;count++){
			flg = 1;
			memset(tmp,0,sizeof(tmp));
			rep(i,n)rep(j,n)if(p[i]==p[j])tmp[j]++;
			rep(i,n)if(p[i]!=tmp[i]){flg=0;break;}
			if(flg) break;
			rep(i,n)p[i]=tmp[i];
		}
		cout<<count<<endl;
		rep(i,n-1)cout<<p[i]<<" ";
		cout<<p[n-1]<<endl;
	}

	return 0;
}