#include <stdio.h>

void getFA(int *src, int *dst, int n){
  for (int i=0; i<n; i++){
    int cnt=0;
    for (int j=0; j<n; j++){
      if (src[i]==src[j]) cnt++;
    }
    dst[i] = cnt;
  }
}

#define N 12

int main(void){
  int n;
  int cnt;
  int a[N],b[N];
  bool modified;

  while (scanf("%d",&n), n){
    for (int i=0; i<n; i++){
      scanf("%d",&a[i]);
    }
    cnt = 0;
    while (true){
      modified = false;
      getFA(a,b,n);
      for (int i=0; i<n; i++){
	if (a[i]!=b[i]) modified = true;
	a[i] = b[i];
      }
      if (modified){
	cnt++;
      } else {
	break;
      }
    }
    printf("%d\n", cnt);
    for (int i=0; i<n-1; i++){
      printf("%d ",b[i]);
    }
    printf("%d\n", b[n-1]);
  }

  return 0;
}