#include <iostream>

using namespace std;

int n, m;
int S[12], oldS[12], memo[2][12];

void init(void);
void ope(void);
void change(void);
int check(void);
int search(int num);

int main() {
	int ans;

	while (cin >> n) {
		if (n == 0) break;

		for (int i = 0; i < n; i++)
			cin >> oldS[i];
		
		init();
		ope();
		ans = 0;
		m = 0;
		while (check()) {
			change();
			ope();
			ans++;
		}

		cout << ans << endl;
		for (int i = 0; i < n; i++) {
			cout << S[i];
			if (i < 11)
				cout << " ";
		}
		cout << endl;
	}
}

void init(void) {
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < 12; j++) {
			memo[i][j] = -1;
		}
	}
}

void ope(void) {
	int num, cont;
	for (int i = 0; i < n; i++) {
		num = oldS[i];
		cont = 0;
		if (search(num)) {
			cont = search(num);
		}
		else {
			for (int j = 0; j < n; j++) {
				if (oldS[j] == num)
					cont++;
			}
			memo[0][m] = num;
			memo[1][m] = cont;
		}
		S[i] = cont;
	}
}

void change(void) {
	for (int i = 0; i < n; i++) {
		oldS[i] = S[i];
	}
}

int check(void) {
	for (int i = 0; i < n; i++) {
		if (oldS[i] != S[i])
			return 1;
	}

	return 0;
}

int search(int num) {
	for (int i = 0; i < 12; i++) {
		if (memo[0][i] == num) {
			return memo[1][i];
		}
	}

	return 0;
}