#include <iostream>
using namespace std;

int main(){
	int n, a[12], b[12], in, sum, kaisu;
	while(cin >> n){
		if (n == 0) { break; }
		for(int i = 0;i<12;i++){
			if (i < n) { cin >> a[i]; }
			else { a[i] = 0; }
		}
		kaisu = 0;
		while(true){
			sum = 0;
			for(int i = 0;i<n;i++){
				b[i] = 0;
				for(int j = 0;j<n;j++){
					if (a[i] == a[j]) { b[i]++; }
				}
				if (a[i] == b[i]) { sum++; }
			}
			for(int i = 0;i<n;i++){
				a[i] = b[i];
			}
			if (sum == n) { break; }
			kaisu++;
		}
		cout << kaisu << endl
			<< a[0];
		for(int i = 1;i<n;i++){
			cout << " " << a[i];
		}
		cout << endl;
	}
	return 0;
}