#include <cstdio>

int main(void)
{
	int n;
	int i, j;
	int count, ct, k;
	int num[2][15];
	
	while (scanf("%d", &n), n){
		count = 0;
		for (i = 0; i < n; i++){
			scanf("%d", &num[0][i]);
		}
		k = 0;
		while (1){
			for (i = 0; i < n; i++){
				ct = 0;
				for (j = 0; j < n; j++){
					if (num[k][i] == num[k][j]) ct++;
				}
				num[1 - k][i] = ct;
			}
			ct = 0;
			for (i = 0; i < n; i++){
				if (num[0][i] == num[1][i]) ct++;
			}
			if (ct == n){
				break;
			}
			k = 1 - k;
			count++;
		}
		
		printf("%d\n%d", count, num[0][0]);
		for (i = 1; i < n; i++){
			printf(" %d", num[0][i]);
		}
		printf("\n");
	}
	return (0);
}