#include<iostream>

using namespace std;

int main(){
	int in;

	while(cin >> in){
		int rev = 0, max = 0;

		if(in == 0) break;

		int data[in];

		for(int i = 0; i < in; i++){
			cin >> data[i];
			if(data[i] > max) max = data[i];
		}

		while(1){

			int sum[max+1];

			for(int	i = 0; i <= max; i++){
				sum[i] = 0;
			}
		
			for(int i = 0; i < in; i++){
				sum[data[i]]++;
			}

			int status = 0;

			for(int i = 0; i < in; i++){
				if(data[i] != sum[data[i]]) status = 1;
			}

			/*for(int i = 0; i < in; i++) cout << data[i] << " ";
			cout << endl;*/

			if(status == 0){
				cout << rev << endl;
				for(int i = 0; i < in; i++){
					if(i != 0) cout << " ";
					cout << data[i];
				}
				cout << endl;
				break;
			}

			for(int i = 0; i < in; i++){
				data[i] = sum[data[i]];
			}
			rev++;
			max = in;
		}
	}

	return 0;
}