#include <iostream>
using namespace std;

int main()
{
    int n;
    while(cin >> n){
        if(n==0)
            break;
         int s[2][12];
         for(int i=0;i<n;i++){
             cin >> s[0][i];
         }
         int dif,cycle=0;
         do{
             dif = 0;
             for(int i=0;i<n;i++){
                 int a = 0;
                 for(int k=0;k<n;k++){
                     if(s[0][i]==s[0][k])
                         a++;
                 }
                 s[1][i] = a;
             }
             
             for(int i=0;i<n;i++){
                 if(s[0][i]!=s[1][i])
                     dif++;
                 s[0][i] = s[1][i];
             }
             cycle++;
         }while(dif != 0);
         
         cout << --cycle << endl;
         for(int i=0;i<n;i++){
             if(i!=0)
                 cout << " ";
             cout << s[0][i];
         }
         cout << endl;
     }
     return 0;
 }