#include <bits/stdc++.h>

using namespace std;

int SData[12], CData[12];
int CountOfData[101];

int solve(int n) {
	int count;
	bool flag;
	
	count = 0;
	while (1) {
		flag = false;
		for (int i = 0; i < n; i++) {
			CData[i] = CountOfData[SData[i]];
		}

		for (int i = 0; i < n; i++) {
			if (CData[i] != SData[i]) {
				flag = true;
				break;
			}
		}
		if (flag) {
			count++;
		}
		else
		{
			return count;
		}

		memset(CountOfData, 0, sizeof(CountOfData));
		for (int i = 0; i < n; i++) {
			SData[i] = CData[i];
			CountOfData[CData[i]]++;
		}
	}
	
}

int main() {
	int n, sum;

	while (cin >> n, n) {
		memset(CountOfData, 0, sizeof(CountOfData));
		for (int i = 0; i < n; i++) {
			cin >> SData[i];
			CountOfData[SData[i]]++;
		}

		sum = solve(n);
		cout << sum << endl;
		for (int i = 0; i < n; i++) {
			cout << SData[i];
			if (i != n - 1) {
				cout << " ";
			}
		}
		cout << endl;
	}


	return 0;
}
