#include <cstdio>
#include <cstring>
#define buf 10000
using namespace std;

void BubbleSort(int n);
void Search(int n);
void Answer(int n,int ans);
void Copy(int n);
int A[300],B[300],C[300]={0};

int main(void){
  int i,n,m,num,ans;
  char str[buf],*line;

  for( ;fgets(str,sizeof(str),stdin)!=NULL; ){
    sscanf(str,"%d",&n);
    if(n==0) break; ans=0;
    fgets(str,sizeof(str),stdin);
    line=strtok(str," ");
    sscanf(line,"%d",&m); A[0]=m;
    for(i=1;i<n;i++){
      line=strtok(NULL," ");
      sscanf(line,"%d",&m);
      A[i]=m;
    }
    for( ; ; ){
      Copy(n);
      BubbleSort(n);
      Search(n);
      num=0;
      for(i=0;i<n;i++){
        if(A[i]==C[i])
          num++;
      }
      if(num==n)
        break;
      else{
        for(i=0;i<n;i++)
          C[i]=A[i];
        ans+=1;
      }
    }
    Answer(n,ans);
  }
  return 0;
}

void Copy(int n){
  int i;
  for(i=0;i<n;i++){
    B[i]=A[i];
  }
}

void Answer(int n,int ans){
  int i;
  printf("%d\n",ans);
  for(i=0;i<n;i++){
  if(i) printf(" ");
     printf("%d",A[i]);
  }
  printf("\n");
}

void Search(int n){
  int i,j,tmp=0,cnt=1;
  for(i=0;i<n;i++){
    if(B[i]==B[i+1])
      cnt+=1;
    else{
      for(j=0;j<n;j++){
        if(B[tmp]==A[j])
          A[j]=cnt;
      }
      tmp=i+1; cnt=1;
    }
  }
}

void BubbleSort(int n){
  int i,j,tmp;
  for(i=0;i<n-1;i++){
    for(j=n-1;j>i;j--){ 
      if(B[j] < B[j-1]){
        tmp = B[j-1];
        B[j-1] = B[j];
        B[j] = tmp;
      }
    }
  }
}