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

using namespace std;

int main(void) {
	while(1) {
		int c = 0, n, S1[12], S2[12];
		
		cin >> n;
		if(n == 0) { break; }
		for(int i = 0; i < n; i++) {
			cin >> S1[i];
		}
		memset(S2, 0, sizeof(S2));
		while(1) {
			for(int i = 0; i < n; i++) {
				for(int j = 0; j < n; j++) {
					if(S1[i] == S1[j]) {
						S2[i]++;
					}
				}
			}
			if(memcmp(S1, S2, sizeof(S1)) == 0) { break; }
			memcpy(S1, S2, sizeof(S2));
			memset(S2,  0, sizeof(S2));
			c++;
		}
		cout << c << endl;
		for(int i = 0; i < n; i++) {
			if(i == 0) {
				cout << S1[i];
			} else {
				cout << ' ' << S1[i];
			}
		}
		cout << endl;
	}
	return 0;
}