#include <iostream>
#include <cstdlib>

using namespace std;

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

int main(int argc, char **argv)
{
	int n, *a, *b, *c, s;
	
	while(1){
		cin >> n;
		if(n == 0){
			break;
		}
		a = (int *)calloc(n+1, sizeof(int));
		b = (int *)calloc(n+1, sizeof(int));
		c = (int *)calloc(13, sizeof(int));
		for(int i = 0; i < n; i++){
			cin >> a[i];
			c[a[i]]++;
		}
		for(int i = 0; i < n; i++){
			b[i] = a[i];
			a[i] = c[a[i]];
		}
		s = 0;
		while(func(a, b, n)){
			for(int i = 0; i < n; i++){
				b[i] = a[i];
				a[i] = c[a[i]];
			}
			for(int i = 0; i < n; i++){
				c[i] = 0;
			}
			for(int i = 0; i < n; i++){
				c[a[i]]++;
			}
			s++;
		}
		s--;
		cout << s << endl;
		for(int i = 0; i < n-1; i++){
			cout << a[i] << " ";
		}
		cout << a[n-1] << endl;
		
		free(c);
		free(b);
		free(a);
	}
	
	return 0;
}