#include <cstdio>
#include <algorithm>
#define REP(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) REP(i,0,n)
int a[2][13], n, f, c;
int main()
{
    while (scanf("%d", &n), n) {
        rep(i, n) scanf("%d", &a[0][i]);
        c = f = 0;
        while (true) {
            bool ok = true;
            rep(i, n) if (a[0][i] != a[1][i]) ok = false;
            if (ok) break;
            rep(i, n) a[1-f][i] = std::count(a[f], a[f] + n, a[f][i]);
            f = 1 - f;
            c++;
        }
        printf("%d\n", c-1);
        rep(i, n-1) printf("%d ", a[f][i]); printf("%d\n", a[f][n-1]);
    }
    return 0;
}