#include <iostream>
#include <map>
#include <cstring>
using namespace std;
int main(){
	int n, s[12] = {0};
	while(cin >> n,n){
	for(int i = 0;i < n;i++){
		cin >> s[i];
	}

	int turn = 0;
	for(int i=10;i;i--){
		turn++;
		map<int,int> m;
		for(int i = 0;i < n;i++){
			m[s[i]]++;
		}//ツ古つ青板チツェツッツク
		int c[12];
		
		for(int i = 0;i < n;i++){
			c[i] = m[s[i]];
		}
		int j = 0;
		for(int i = 0;i < n;i++){
			j += (s[i] == c[i]);
		}

		if(j == n){
			cout << turn - 1 << endl;
			cout << s[0];
			for(int i = 1;i < n;i++){
				cout << " " << s[i];
			}
			cout << endl;
			break;
		}
		memcpy(s,c,sizeof(s));
	}
	}
}