#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define EPS 1e-9
using namespace std;
typedef long long ll;
typedef pair<string, int>P;

int main() {
	int n;
	while (cin >> n, n) {
		vector<int>S, P;
		rep(i, n) {
			int a; scanf("%d", &a);
			S.push_back(a);
		}
		int cnt = 0;
		while (1) {
			rep(i, n) {
				P.push_back(count(S.begin(), S.end(), S[i]));
			}
			if (P == S)break;
			S = P;
			P.clear();
			cnt++;
		}
		cout << cnt << endl;
		rep(i, P.size()) {
			cout << P[i] << (i == P.size() - 1 ? '\n' : ' ');
		}
	}
}