#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
	int n;
	while(cin >> n, n){
		vector<int> a(n, 0), b(n, 0);
		for(int i = 0;i < n;i++)cin >> b[i];
		int ans = 0;
		while(1){
			for(int i = 0;i < n;i++)
				a[i] = count(b.begin(), b.end(), b[i]);
			if(a == b)break;
			b = a;ans++;
		}
		cout << ans << endl;
		for(int i = 0;i < n;i++)
			cout << b[i] << (i == n-1 ? "\n" : " ");
	}
	return 0;
}