#include <bits/stdc++.h>

using namespace std;
typedef map<int, int> mii;

bool check(mii mp) {
    mii::iterator it;
    for (it = mp.begin(); it != mp.end(); it++)
        if ((*it).first != (*it).second) return false;
    return true;
}

int main(void) {
    int n, s[110];
    while (cin >> n, n) {
        int ans = 0;
        mii mp, pre;
        for (int i = 0; i < n; i++) {
            cin >> s[i];
            mp[s[i]]++;
        }
        
        while (!check(mp)) {
            ans++;
            pre = mp;
            mp.clear();
            for (int i = 0; i < n; i++) {
                s[i] = pre[s[i]];
                mp[s[i]]++;
            }
        }

        cout << ans << endl;
        for (int i = 0; i < n; i++) {
            if (i) cout << " ";
            cout << s[i];
        }
        cout << endl;
    }
}
