#include <iostream>
using namespace std;
bool issame(int *a,int *b,int n){
	for(int i = 0;i < n;++i){
		if(a[i] != b[i]) return false;
	}
	return true;
}
int main(){
	int n,seq[12],count,tmp[12];
	bool f;
	while(cin >> n,n){
		f = false;
		count = 0;
		for(int i = 0;i < n;++i){
			cin >> seq[i];
		}
		while(!f){
			for(int i = 0;i < n;++i){
				int same = 0;
				for(int j = 0;j < n;++j){
					if(seq[i] == seq[j]) ++same;
				}
				tmp[i] = same;
			}
			++count;
			f = issame(seq,tmp,n);
			for(int i = 0;i < n;++i){
				seq[i] = tmp[i];
				tmp[i] = 0;
			}
		}
		cout << count - 1 << endl;
		for(int i = 0;i < n;++i){
			if(i) cout << " ";
			cout << seq[i];
		}
		cout << endl;
	}
	return 0;
}