#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <map>
#include <numeric>
#include <sstream>
#include <queue>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()
#define print(s) cout << (s) << endl
#define printV(v) for(int zxc=0;zxc<v.size()-1;zxc++){cout << v[zxc] << " ";} cout << v.back() << endl;

vector<int> freq(vector<int> v) {
    vector<int> w(v);
    vector<int> a(v.size(),0);
    sort(ALL(w));
    REP(i,v.size()) {
        a[i] += upper_bound(ALL(w), v[i]) - lower_bound(ALL(w), v[i]);
    }
    return a;
}

bool same(vector<int> a, vector<int> b) {
    REP(i,a.size()) if (a[i] != b[i]) return false;
    return true;
}

void solve108(int n) {
    vector<int> v;
    PUSH(n,v);
    int cnt = 0;
    vector<int> a;
    while (true) {
        a = freq(v);
        if (same(v,a)) break;
        v = a;
        cnt++;
    }
    cout << cnt << endl;
    printV(a);
}

int main() {
    int n;
    while (cin >> n, n) {
        solve108(n);
    }
    return 0;
}