#include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#include<map>
#include<stack>
#include<queue>
#include<algorithm>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    int  n;
    while(cin >> n, n){
        int i = 0, s[15], ap[1024] = {0};
        rep(j,n){
            cin >> s[j];
            ap[s[j]]++;
        }
        int sub[15], ans = 0;;
        while(true){
            rep(j,n){
                sub[j] = ap[s[j]];
            }
            bool c = true;
            rep(j,1024) ap[j] = 0;
            rep(j,n){
                if(s[j] != sub[j]) c = false;
                s[j] = sub[j];
                ap[s[j]]++;
            }
            if(c) break;
            ans++;
        }
        cout << ans << endl;
        rep(j,n){
            if(j) cout << ' ';
            cout << s[j];
        }cout << endl;
    }
    
}