#include<iostream>
#include<vector>
using namespace std;
vector<int> f(vector<int> v) {
	int cnt[110] = {};
	for (int i = 0; i < v.size(); i++) 
		cnt[v[i]]++;
	vector<int> r;
	for (int i = 0; i < v.size(); i++)
		r.push_back(cnt[v[i]]);
	return r;
}
int main() {
	int n;
	while (cin >> n, n) {
		vector<int>b, a;
		for (int i = 0; i < n; i++) {
			int k; cin >> k;
			b.push_back(k);
		}
		int cnt = 0;
		while (true) {
			cnt++;
			a = f(b);
			if (a == b)break;
			b = a;
		}
		cout << --cnt << endl;
		for (int i = 0; i < a.size(); i++) {
			if (i)cout << ' '; cout << b[i];
		}cout << endl;
	}
}