#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <cstdio>
#include <algorithm>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

int main()
{
    int n;
    while (1) {
        int cnt[13] = { 0 };
        cin >> n;
        if (n == 0) break;
        REP(i, n) cin >> cnt[i];
        int pre[13] = { 0 };
        for(int k = 0, f = 1; ; k++, f = 1) {
            int sum[100] = { 0 };
            REP(i, n) {
                pre[i] = cnt[i];
                sum[pre[i]]++;
            }
            REP(i, n) {
                cnt[i] = sum[pre[i]];
                if (cnt[i] != pre[i]) f = 0;
            }
            if (f) {
                cout << k << endl;
                REP(i, n) {
                    if (i < n - 1) printf("%d ", cnt[i]);
                    else printf("%d\n", cnt[i]);
                }
                break;
            }
        }
    }
    return 0;
}