#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main() {
    int n;
    while (cin >> n, n) {
        int ans = 0;
        vector<int> v(n);
        for (int i=0; i<n; ++i) cin >> v[i];
        while (1) {
            vector<int> v2(n);
            for (int i=0; i<n; ++i) {
                int cnt = 0;
                for (int j=0; j<n; ++j) cnt += v[i] == v[j];
                v2[i] = cnt;
            }
            if (v == v2) break;
            v = v2;
            ans ++;
        }
        cout << ans << endl;
        for (int i=0; i<n; ++i) {
            cout << (i==0 ? "" : " ") << v[i];
        }
        cout << endl;
    }
    return 0;
}