#include <stdio.h>
#include <iostream>

using namespace std;

int main() {
	int n;
	int number[12];
	int hantei;
	int count;

	while (cin >> n) {
		if (n == 0) {
			break;
		}
		int counter[100] = {0};
		for (int i = 0; i < n; i++) {
			cin >> number[i];
			counter[number[i]-1]++;
		}
		hantei = 0;
		count = 0;
		while (1) {
			for (int i = 0; i < n; i++) {
				if (number[i] == counter[number[i]-1]) {
					if (i == n-1) {
						hantei = 1;
						break;
					}
					continue;
				} else {
					break;
				}
			}
			if (hantei == 1) {
				break;
			}
			for (int i = 0; i < n; i++) {
				number[i] = counter[number[i]-1];
			}
			for (int i = 0; i < 100; i++) {
				counter[i] = 0;
			}
			for (int i = 0; i < n; i++) {
				counter[number[i]-1]++;
			}
			count++;
		}
		cout << count << endl;
		cout << number[0];
		for (int i = 1; i < n; i++) {
			cout << " " << number[i] ;
		}
		cout << endl;
	}
	return 0;
}