#include <iostream>
using namespace std;

bool jug(int* s1, int* s2, int len){
    for(int i = 0; i < len; ++i) {
        if (s1[i] != s2[i]) return false;
    }
    return true;
}
int main(){
    int n,count,tmp,x;
    int* s = new int[12];
    int* ans = new int[12];
    while(true) {
        cin >> n;
        if (n ==  0) {
            break;
            cout << endl;
        }
        for(int i = 0; i < n; ++i) {
            cin >> s[i];
        }
        x = 0;
        while(true){
            for(int i = 0; i < n; ++i) {
                count = 0;
                for(int j = 0; j < n; ++j) {
                    if (s[i] == s[j]) {
                        ++count;
                    }
                }
                ans[i] = count;
            }
            if (jug(s, ans, n)) break;
            x++;

            for (int i = 0; i < n; i++) {
                tmp = s[i];
                s[i] = ans[i];
                ans[i] = tmp;
            }
        }
        cout << x << endl;
        for (int i = 0; i < n; i++) {
            cout << s[i];
            if (i == n-1) {
                break;
            }
            cout << " ";
        }
        cout << endl;
    }
    delete s;
    delete ans;
}