/*
	0108:Operation of Frequency of Appearance
*/
#include	<iostream>
#include	<cstring>

using namespace std;

int main(void) {
	int n, count, S[12], P[12];
	while(1) {
		count = 0;
		cin >> n;
		if(n == 0) { break; }
		for(int i = 0; i < n; i++) {
			cin >> S[i];
		}
		memset(P, 0, sizeof(P));
		while(1) {
			for(int i = 0; i < n; i++) {
				for(int j = 0; j < n; j++) {
					if(S[i] == S[j]) { P[i]++; }
				}
			}
			if( memcmp( P, S, sizeof(S) ) == 0) { break; }

			memcpy(S, P, sizeof(P));
			memset(P, 0, sizeof(P));
			count++;
		}
		cout << count << endl;
		for(int i = 0; i < n; i++) {
			if(i == 0) {
				cout << S[i];
			} else {
				cout << ' ' << S[i];
			}
		}
		cout << endl;
	}
	return 0;
}