#include <bits/stdc++.h>
using namespace std;

#define for_(i,a,b) for(int i=(a);i<(b);++i)

int main() {
	int n, s[15];
	
	while (cin >> n, n) {
		for_(i,0,n) cin >> s[i];
		
		bool update = 1;
		int ans = 0;
		
		while (update) {
			update = 0;
			
			map< int, int > cnt;
			for_(i,0,n) ++cnt[s[i]];
			
			for_(i,0,n) {
				if (s[i] != cnt[s[i]]) update = 1;
				s[i] = cnt[s[i]];
			}
			
			if (update) ++ans;
		}
		
		cout << ans << endl;
		for_(i,0,n) cout << s[i] << (i < n - 1 ? " " : "\n");
	}
}