#include<cstdio>
#include<algorithm>
using namespace std;
int main(){

  int n,s[101],v[13],flag,count;
  
  scanf("%d",&n);
  
  while(n != 0){
    fill(s,s+101,0);
    
    count = 0;
    for(int i=0;i<n;i++){
      scanf("%d",&v[i]);
      s[v[i]]++;
    }
    
    while(1){
      flag = 0;
      for(int i=0;i<n;i++){
	if(v[i] != s[v[i]]){
	  v[i] = s[v[i]];
	  flag++;
	}
      }
      
      if(flag == 0) break;
      
      fill(s,s+101,0);
      for(int i=0;i<n;i++){
	s[v[i]]++;
      }
      
      count++;
    }
    printf("%d\n",count);
    for(int i=0;i<n;i++){
      if(i != n-1) printf("%d ",v[i]);
      else printf("%d\n",v[i]);
    }
    scanf("%d",&n);
  }
  
  return (0);
}