#include<iostream>
#include<map>
using namespace std;
int main(void){

    int n;

    while(cin>>n){
        if(n==0)break;
        int a[13];
        map<int,int> b;
        int c[13];
        for(int i=0;i<n;i++){
            cin>>a[i];
            b[a[i]]++;
        }
        int j=0;
        while(1){

            bool flg = false;
            for(int i=0;i<n;i++){
                c[i] = b[a[i]];
                if(c[i]!=a[i])flg = true;
                //cout<<c[i]<<" ";
            }
            //cout<<endl;
            if(!flg)break;
            for(int k=0;k<n;k++)b[k]=0;
            for(int k=0;k<n;k++){
                a[k] = c[k];
                b[a[k]]++;
            }
            j++;
        }
        cout<<j<<endl;
        for(int i=0;i<n;i++){
            cout<<c[i]<<" ";
        }
        cout<<endl;

    }

    return 0;
}