/*
	AOJ_0108: Operation of Frequency of Appearance
*/
#include	<iostream>
#include	<cstring>
#include	<queue>

using namespace std;

class Sequence {
private:
	int elements[12];	//数列の要素
	int length;			//数列の長さ
	const int _EMPTY;	//空欄を表す定数
public:
	/*コンストラクタ*/
	Sequence() : _EMPTY(-65536){
		for (int i = 0; i < 12; i++) {
			elements[i] = _EMPTY;
		}
	}
	/*メンバ関数*/
	void Insert(int ln, int *elm) {
		length = ln;
		for (int i = 0; i < ln; i++) {
			elements[i] = elm[i];
		}
	}
	int Operation(void) {
		int Order[12], Result[12], target_number, target_count;

		for (int i = 0; i < length; i++) {
			Order[i] = elements[i];
		}
		for (int i = 0; i < length; i++) {
			queue<int> listChange;
			target_count = 0;
			if (Order[i] == _EMPTY) { continue; }
			target_number = Order[i];
			for (int j = i; j < length; j++) {
				if (Order[j] == _EMPTY) { continue; }
				if (Order[j] == target_number) {
					Order[j] = _EMPTY;
					listChange.push(j);
					target_count++;
				}
			}
			while (!listChange.empty()) {
				Result[listChange.front()] = target_count;
				listChange.pop();
			}
		}
		if (memcmp(Result, elements, sizeof(int) * length) == 0) {
			return 1;
		} else {
			for (int i = 0; i < length; i++) {
				elements[i] = Result[i];
			}
			return -1;
		}
	}
	void ShowSequence() {
		for (int i = 0; i < length; i++) {
			if (i != 0) { cout << ' '; }
			cout << elements[i];
		}
		cout << endl;
	}
};

int main(void) {
	int length, s[12], t;
	
	while (1) {
		Sequence SEQ;
		t = 0;

		cin >> length;
		if (length == 0) { break; }

		for (int i = 0; i < length; i++) {
			cin >> s[i];
		}
		SEQ.Insert(length, s);
		while (SEQ.Operation() == -1) { t++; }
		cout << t << endl;
		SEQ.ShowSequence();
	}

	return 0;
}