#include<iostream>
using namespace std;

int main(){
	int n;
	int C[12];
	while(1){
		cin >> n;
		if(n == 0) break;
		for(int i=0;i<n;i++){
			cin >> C[i];
		}
		int ans = 0;
		int cou = 0;
		while(1){
			if(cou == n) break;
			cou = 0;
			int k[12]={0};
			for(int i=0;i<n;i++){
				int tmp = C[i];
				for(int j=0;j<n;j++){
					if(tmp == C[j]){
						k[i]++;
					}
				}
			}
			for(int i=0;i<n;i++){
				if(C[i] == k[i]){
					cou++;
				}
				C[i] = k[i];
			}
			ans++;
		}
		ans--;
		cout << ans << endl;
		for(int i=0;i<n;i++){
			cout << C[i];
			if(n != i+1) cout << " ";
		}
		cout << endl;
	}
}