#include <cstdio>
using namespace std;

int main(void)
{
    while (1){
        int n;
        scanf("%d", &n);
        if (!n) break;
        int num[13] = {0};
        int prev[13] = {0};
        int ans = 0;
        for (int i = 0; i < n; i++){
            scanf("%d", &num[i]);
        }
        while (1){
            ans++;
            for (int i = 0; i < n; i++){
                prev[i] = 0;
                for (int j = 0; j < n; j++){
                    if (num[i] == num[j]){
                        prev[i]++;
                    }
                }
            }
/*            printf("%d\n", ans);
            for (int i = 0; i < n; i++){
                printf("%d", prev[i]);
                ((i + 1) == n) ? printf("\n") : printf(" ");
            }*/
            
            bool flag = true;
            for (int i = 0; i < n; i++){
                if (num[i] != prev[i]) flag = false;
            }
            if (flag) break;
            
            for (int i = 0; i < n; i++){
                num[i] = prev[i];
            }
        }
        printf("%d\n", ans - 1);
        for (int i = 0; i < n; i++){
            printf("%d", num[i]);
            ((i + 1) == n) ? printf("\n") : printf(" ");
        }
    }
    
    return (0);
}