#include<iostream>
using namespace std;

int main()
{
    int n, s[12] = {0}, c[101] = {0};
    int p[12] = {0};

    while( cin >> n )
    {
        if( n == 0 )
            break;
    
        for( int i = 0; i < n; i++ )
            cin >> s[i];

        int cnt = 0;
        bool judge = false;
        while( judge == false )
        {
            for( int i = 0; i < 101; i++ )
                c[i] = 0;

            for( int i = 0; i < n; i++ )
            {
                p[i] = s[i];
                c[s[i]]++;
            }

            for( int i = 0; i < n; i++ )
                s[i] = c[s[i]];

            for( int i = 0; i < n; i++ )
            {
                if( p[i] != s[i] )
                {
                    judge = false;
                    cnt++;
                    break;
                }
                else
                    judge = true;
            }
        }

        cout << cnt << endl;
        for( int i = 0; i < n; i++ )
        {
            cout << s[i];
            if( i != n - 1 )
                cout << " ";
        }
        cout << endl;
    }
    return 0;
}
