#include <iostream>

using namespace std;

int main()
{
	int n;
	int count;
	int num[2][15];
	
	while (cin >> n, n){
		count = 0;
		for (int i = 0; i < n; i++){
			cin >> num[0][i];
		}
		int ct, k = 0;
		while (1){
			for (int i = 0; i < n; i++){
				ct = 0;
				for (int j = 0; j < n; j++){
					if (num[k][i] == num[k][j]) ct++;
				}
				num[1 - k][i] = ct;
			}
			ct = 0;
			for (int i = 0; i < n; i++){
				if (num[0][i] == num[1][i]) ct++;
			}
			if (ct == n){
				break;
			}
			k = 1 - k;
			count++;
		}
		
		cout << count << endl << num[0][0];
		for (int i = 1; i < n; i++){
			cout << ' ' << num[0][i];
		}
		cout << endl;
	}
	return (0);
}