#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
using namespace std;
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    while(cin >> n){
        if(!n) break;

        vector<int> s(n),t(n);
        map<int,int> memo;
        rep(i,n) cin >> s[i];

        int cnt = 0;
        bool ok = true;
        while(ok){
            memo.clear();
            rep(i,n) memo[ s[i] ]++;
            rep(i,n) t[i] = memo[ s[i] ]; 
            if(s == t) break;
            s = t; cnt++;
        }
        cout << cnt << endl;
        rep(i,n-1) cout << t[i] << " ";
        cout << t[n-1] << endl;
    }

    return 0;
}
