#include<iostream>
using namespace std;
bool OperationFA( int *an , int n ){
	bool ret = true;
	int *cn = new int[n];
	
	for(int i = 0; i < n; i++){
		int mode = 0;
		for(int j = 0; j < n; j++){
			if( an[j] == an[i] ) mode++;
		}
		cn[i] = mode;
	}
	for(int i = 0; i < n; i++){
		if( an[i] != cn[i] ) ret = false;
		an[i] = cn[i];
	}
	delete []cn;
	return ret;
}
int main(void){
	while( true ){
		int n;
		int cnt = 0;
		int *an;

		cin >> n;
		if( n == 0 ) break;
		an = new int[n];

		for(int i = 0; i < n; i++){
			cin >> an[i];
		}

		while ( true ){
			if( OperationFA( an, n ) ) break;
			cnt++;
		}

		cout << cnt << '\n';
		cout << an[0];
		for(int i = 0; i < n; i++){
			cout << ' ' << an[i];
		}
		cout << '\n';
		delete []an;
	}
	return 0;
}