#include<iostream>
#include<vector>
using namespace std;

int main(){
	vector<int> now, next;
	int len;
	while( cin >> len, len ){
		now.resize(len);
		next.resize(len);
		for( int i=0; i<len; i++ ){
			cin >> next[i];
		}
		int ope=0;
		while(!(now == next)){
			ope++;
			for( int i=0; i<len; i++ )	now[i] = next[i];
			for( int i=0; i<len; i++ ){
				int cnt=0;
				for( int j=0; j<len; j++ ){
					if( now[i] == now[j] )	cnt++;
				}
				next[i] = cnt;
			}
		}
		cout << ope-1 << endl;
		cout << now[0];
		for( int i=1; i<len; i++ ){
			cout << " " << now[i];
		}
		cout << endl;
	}
	return 0;
}