#include <iostream>
using namespace std;

int main(){
    int n;
    while(cin >> n, n != 0){
        int v[n];
        int cnt = 0;
        for(int i=0; i<n; ++i){
            cin >> v[i];
        }
        while(1){
            int tmp[n];
            bool flug = true;
            for(int i=0; i<n; ++i){
                tmp[i] = 0;
                for(int j=0; j<n; ++j)
                    if(v[i] == v[j]) ++tmp[i];
                if(v[i] != tmp[i]) flug = false;
            }
            if(flug) break;
            cnt++;
            for(int i=0; i<n; ++i)
                v[i] = tmp[i];
        }
        cout << cnt << endl;
        for(int i=0; i<n; ++i)
            cout << ((i!=0)?" ":"") << v[i];
        cout << endl;
    }
    return 0;
}