#include<iostream>
using namespace std;

int main() {
	int n;
	while (cin >> n, n) {
		int suret[12];
		int cpy[12];
		for (int i = 0;i < n;i++)cin >> suret[i];

		int ans = 0;
		while (1) {
			for (int i = 0;i < n;i++) {
				int a = 0;
				for (int j = 0;j < n;j++) {
					if (suret[i] == suret[j])a++;
				}
				cpy[i] = a;
			}
			int flg = 1;
			for (int i = 0;i < n;i++) {
				if (suret[i] != cpy[i])flg = 0;
				suret[i] = cpy[i];
			}
			if (flg == 1)break;
			ans++;
		}
		cout << ans << endl;
		for (int i = 0;i < n;i++){
			cout << suret[i];
			if (i != n - 1)cout << ' ';
		}
		cout << endl;
	}
	return 0;
}