#include<iostream>
#include<string>
using namespace std;
int main() {
	int n;
	while (cin >> n&&n != 0) {
		int b[12],c=0;
		string e[2] = { "","" };
		int d[101];
		fill(d, d + 101, 0);
		for (int i = 0; i < n; i++) {
			cin >> b[i];
			e[1] += to_string(b[i]);
			d[b[i]]++;
		}
		string h = "";
		c = 0;
		while (e[0] != e[1]) {
			e[0] = e[1];
			e[1] = "";
			for (int i = 0; i < n; i++) 
				b[i] = d[b[i]];
			fill(d, d + 101, 0);
			for (int i = 0; i < n; i++) {
				d[b[i]]++;
				e[1] += to_string(b[i]);
			}
			c++;
		}
		cout << c - 1 << endl;
		for (int i = 0; i < n; i++) {
			if (i == 0)
				cout << b[i];
			else
				cout << " " << b[i];
		}
		cout << endl;
	}
}