#include <iostream>
using namespace std;
int main(){
	int n,s[12],o[12];
	while(cin>>n){
		if(!n)break;
		int step=-1;
		for(int i=0;i<n;++i) cin>>s[i];
		for(int f=1;f;++step){
			for(int i=0;i<n;++i) o[i]=s[i];
			for(int i=0,count=0;i<n;++i){
				count=0;
				for(int j=0;j<n;++j){
					if(o[i]==o[j])++count;
				}
				s[i]=count;
			}
			f=0;
			for(int i=0;i<n;++i) if(s[i]!=o[i])f=1;
		}
		cout<<step<<"\n";
		for(int i=0;i<n;++i) cout<<s[i]<<((i!=n-1)?" ":"\n");
	}
	return 0;
}