#include <bits/stdc++.h>
#define MAX_N 15
using namespace std;

int data[MAX_N];
int n;

void print() {
    for(int r = 0; r < n; r++) {
        printf("%d ", data[r]);
    }
    putchar('\n');
}

bool judge() {
    for(int r = 0; r < n; r++) {
        if(count(data, data+n, data[r]) != data[r]) return(false);
    }
    return(true);
}

void convert() {
    int tmp[n];
    for(int r = 0; r < n; r++) {
        tmp[r] = (int)count(data,data+n,data[r]);
    }
    memcpy(data, tmp, sizeof(tmp));
}

int solve() {
    int res = 0;
    do {
        convert();
        res++;
    }while(!judge());
    return(res);
}

int main(void) {
    while(cin >> n, n != 0) {
        for(int r = 0; r < n; r++) {
            cin >> data[r];
        }
        printf("%d\n", solve());
        print();
    }
    return(0);
}