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

int n = 0;
int counter = 0;

vector<int> operation_of_fa(const vector<int> num_seq);

int main()
{
	int num = 0;
	while (true) {
		cin >> n;
		if(n==0) break;
		vector<int> first_num_seq;
		for(int i=0;i<n;i++) {
			cin >> num;
			first_num_seq.push_back(num);
		}

		vector<int> operated_seq = operation_of_fa(first_num_seq);

		cout << counter << endl;
		for(int i=0; i<n; i++) 
			cout << operated_seq[i] << ' ';
		cout << endl;
	}
	return 0;
}


vector<int> operation_of_fa(const vector<int> num_seq)
{
	int frequency = 0;
	vector<int> operated_seq;
	for (int i=0;i<n;i++) {
		frequency = 0;
		for (int j=0;j<n;j++) 
			if (num_seq[i] == num_seq[j])
				frequency++;
		operated_seq.push_back(frequency);
	}
	
	if (num_seq != operated_seq) {
		counter++;
		return operation_of_fa(operated_seq);
	}
	else
		return operated_seq;
}