#include <iostream>
using namespace std;
int main(){
	int i,j,n;
	while(cin >> n, n){
		int p,s[2][14]={0};
		for(i=1;i<=n;i++) cin >> s[0][i];
		for(p=0;;p++){
			for(i=1;i<=n;i++){
				s[1][i]=0;
				for(j=1;j<=n;j++) 
					if(s[0][j] == s[0][i]) s[1][i] ++;
			}
			for(i=1;i<=n;i++) if(s[0][i] != s[1][i]) break;
			if(i>n) break;
			for(i=1;i<=n;i++) s[0][i] = s[1][i];
		}
		cout << p << endl;
		for(i=1;i<=n;i++) cout << s[1][i] << (i==n?"":" ");
		cout << endl;
	}
}