#include <bits/stdc++.h>

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vbb;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair

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

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

int main(){
    int n;
    while(cin >> n, n){
        vi p;
        rep(i, n){int m; cin >> m; p.pb(m); }

        vi v(n, 0);
        int count = 0;
        while(true){
            bool finish = true;
            for(int i=0;i < n; i++){
                if(p[i] != v[i]) finish = false;
            }
            if(finish) break;
            v = p;
            for(int i=0; i < n; i++){
                int c = 0;
                for(int j=0; j < n; j++){
                    if(v[i] == v[j]) c++;
                }
                p[i] = c;
            }
            count++;
        }
        cout << count-1 << endl;
        for(int i=0; i < n; i++){
            if(i == 0) cout << v[i];
            else cout << " " << v[i];
        }
        cout << endl;
    }
}