#include <stdio.h>
#include <string.h>

int main(void)
{
	int s[12];
	int c[12];
	
	while (1){
		int n;
		int count;
		
		scanf("%d", &n);
		
		if (n == 0){
			break;
		}
		
		for (int i = 0; i < n; i++){
			scanf("%d", &s[i]);
		}
		
		count = 0;
		do {
			for (int i = 0; i < n; i++){
				c[i] = 0;
				for (int j = 0; j < n; j++){
					if (s[i] == s[j]){
						c[i]++;
					}
				}
			}
			if (memcmp(s, c, sizeof(int) * n) == 0) break;
			memcpy(s, c, sizeof(s));
			
			count++;
		} while (1);
		
		printf("%d\n", count);
		printf("%d", s[0]);
		for (int i = 1; i < n; i++){
			printf(" %d", s[i]);
		}
		puts("");
	}
	
	return (0);
}