#include <iostream>
#include <stdio.h>
#include <string>
#include <string.h>
#include <queue>
#include <cmath>

#define int64 long long int

using namespace std;
typedef pair<int, int> P;

int freq(int *, int);

int main()
{
    int n, S[12], buf, count;
    
    while(1){
        cin >> n;
        if(n == 0) break;
        
        for (int i=0; i<n; i++) {
            cin >> buf;
            S[i] = buf;
        }
        
        count = 0;
        while(freq(S, n)) count++;
        
        cout << count << endl;
        for(int i=0; i<n-1; i++) cout << S[i] << ' ';
        cout << S[n-1] << endl;
        
    }
    
    return 0;
}

int freq(int *S, int n){
    int C[12] = {0}, buf, flag = 0;
    for(int i=0; i<n; i++){
        buf = S[i];
        for(int j=0; j<n; j++){
            if(S[j] == buf) C[i]++;
        }
    }
    for(int i=0; i<n; i++){
        if(S[i] != C[i]){
            flag = 1;
            break;
        }
    }
    if(flag){
        for(int i=0; i<n; i++) S[i] = C[i];
        return 1;
    }
    return 0;
}