#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    /*
    cin.tie(0);
    ios::sync_with_stdio(false);
    //*/
    int flag = 1;
    int n; cin >> n;
    while (n != 0) {
        int count = 0;
        int p[n];
        int q[101] = {0};
        rep(i, n) {
            cin >> p[i];
        }

        while (flag == 1){
            flag = 0;
            fill(q, q+101, 0);
            rep(i, n) q[p[i]]++;
            //rep(i, n) cout << q[p[i]] << " ";
            for (int i = 0; i < n-1; i++) {
                if (p[i] != q[p[i]]) flag = 1;
            }
            rep(i ,n) p[i] = q[p[i]];
            count++;
        }
        rep(i, n-1) cout << q[p[i]] << " ";
        cout << q[p[n-1]] << endl;
        cout << count-1;
        cin >> n;
    }

    return 0;
}