#include <iostream>
using namespace std;

int main(void){

  int S[12] , P[12] ,n ,c = 0,kaisu = 0,stop = 0;

  

  while(1){


  for( int i = 0 ; i < 12 ; i ++){

    
    S[i] = 0;
    P[i] = 0;



  }


  kaisu = 0;
  stop = 0;
  c = 0;


  cin >> n ;

  if( n == 0 )break;



  for( int i = 0 ; i < n ; i ++){


    cin >> S[i] ;
    
    P[i] = S[i] ;

  }



  while(1){

  for( int i = 0 ; i < n ; i++){

    for( int j = 0 ; j < n ; j++){

      if( S[i] == S[j]) c++  ;
         
          
    }

    P[i] = c ;
    
    c = 0;
  }




  for( int  j = 0 ; j < n ; j++){





    if(  S[j] == P[j] ) stop++  ;
    else continue ; 

   
  
  }

  
   

  if( stop == n  )break;

  stop = 0;

  for( int  j = 0 ; j < n ; j++){

      S[j] = P[j] ;
     
  
  }

 
 
   kaisu++;

 




  }

  cout << kaisu << endl;

  kaisu = 0 ;
  

  for( int i = 0 ; i < n ; i ++){


    cout << P[i] <<' ';


  }

  cout << endl;


  }
  

  return 0;

}