#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int n;
    
    while (cin >> n, n) {
        vector<vector<int> > a(2, vector<int>(n));
        int cnt = 0;
        int f, t;

        f = 0;
        t = 1;
        for (int i = 0; i < n; i++)
            cin >> a[0][i];

        while (a[t] != a[f]) {
            for (int i = 0; i < n; i++) {
                int tmp = 0;
                for (int j = 0; j < n; j++)
                    if (a[f][i] == a[f][j])
                        tmp++;
                a[t][i] = tmp;
            }

            cnt++;
            f = 1 - f;
            t = 1 - t;
        }

        cout << cnt - 1 << endl;
        for (int i = 0; i < n - 1; i++)
            cout << a[t][i] << " ";
        cout << a[t][n - 1] << endl;
    }

    return 0;
}