#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
	vector<int> dt;
	int n;
	while (cin >> n, n) {
		int tmp;
		dt.clear();
		for (int i=0; i<n; i++) {
			cin >> tmp;
			dt.push_back(tmp);
		}

		int cnt = 0;
		while (1) {
			vector<int> t = dt;
			for (int i=0; i<n; i++)
				dt[i] = count(t.begin(), t.end(), t[i]);

			if (t == dt) {
				cout << cnt << endl;
				for (int i=0; i<n-1; i++)
					cout << t[i] << ' ';

				cout << t[n-1] << endl;
				break;
			}
			cnt++;
		}
	}
	return 0;
}