#include <iostream>

bool isSame(int* a, int* b, int n)
{
	for (int i=0; i<n; i++) {
		if (a[i] != b[i]) return false;
	}
	return true;
}

void copy(int *a, int *b, int n)
{
	for (int i=0; i<n; i++) {
		a[i] = b[i];
	}
}

int main()
{
	int n;
	while (true) {
		std::cin >> n;
		if (n==0) break;
		
		int* s = new int[n];
		
		for (int i=0; i<n; i++) {
			std::cin >> s[i];
		}
		
		int* c = new int[n];
		int op_count = 0;
		
		while (true) {
			for (int i=0; i<n; i++) {
				int appearance = 0;
				for (int j=0; j<n; j++) {
					if (s[i] == s[j]) appearance++;
				}
				c[i] = appearance;
			}
			if (isSame(s,c,n)) break;
			copy(s,c,n);
			op_count++;
		}
		
		std::cout << op_count << std::endl;
		for (int i=0; i<n; i++) {
			if (i==0) std::cout << c[i];
			else std::cout << " " << c[i];
		}
		std::cout << std::endl;
		
		delete[] s;
		delete[] c;
	}
	
	return 0;
}


