#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    int n;
    while (cin >> n, n)
    {
        vector<int> s(n), v(n);
        rep(i, n) cin >> s[i];
        int cnt = 0;
        bool flag = 0;
        while (flag != 1)
        {
            copy(ALL(s), v.begin());
            rep(i, n) s[i] = count(ALL(v), v[i]);
            rep(i, n)
            {
                if (s[i] != v[i])
                    break;
                if (i == n - 1)
                    flag = 1;
            }
            cnt++;
        }
        OP(cnt - 1);
        rep(i, n) i != n - 1 ? cout << s[i] << " " : OP(s[i]);
    }
    return 0;
}
