#include <cstdio>
#include <algorithm>
#include <map>
using namespace std;
int arr[12], arr2[12];

int main(){
    int n, idx;
    bool flag;
    for(; ;) {
        scanf("%d", &n);
        if (n == 0) break;
        idx = 0;
        for (int i = 0; i < n; i++) scanf("%d", &arr[i]);

        for (; ;) {
            map<int, int> m;
            for (int i = 0; i < n; i++) {
                if (m.find(arr[i]) == m.end()) m.insert({arr[i], 1});
                else m[arr[i]]++;
            }
            for (int i = 0; i < n; i++) arr2[i] = m[arr[i]];
            flag = true;
            for (int i = 0; i < n; i++) if (arr[i] != arr2[i]) { flag = false; arr[i] = arr2[i]; };
            if (flag) break;
            else idx++;
        }
        printf("%d\n", idx);
        for (int i = 0; i < n; i++) { if(i) printf(" "); printf("%d", arr2[i]); }
        printf("\n");
    }
    return 0;
}

