#include <iostream>
#include <map>

using namespace std;

#define loop(i,a,b) for(int i=(a); i<(b); i++)
#define rep(i,b) loop(i,0,b)

int main(){
    int n;
    while(cin >> n && n){
        int a[15];
        rep(i,n) cin >> a[i];
        int c = 0;
        while(1){
            int cnt[15] = {};
            rep(i,n) cnt[a[i]]++;
            bool up = false;
            rep(i,n){
                if(a[i] != cnt[a[i]]){
                    a[i] = cnt[a[i]];
                    up = true;
                }
            }
            if(!up) break;
            else c++;
        }
        cout << c << endl;
        rep(i,n) cout << a[i] << (i+1==n ? "\n" : " ");
    }
}