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

int main() {
	int n;

	while(cin >> n, n) {
		vector<int> v1, v2;
		int count = 0;

		for(int i = 0; i < n; i++) {
			int tmp;
			cin >> tmp;
			v1.push_back(tmp);
		}

		while(1) {
			count++;
			for(int i = 0; i < n; i++) {
				int tmp = 0;
				for(int j = 0; j < n; j++) {
					if(v1[i] == v1[j])
						tmp++;
				}
				v2.push_back(tmp);
			}

			if(v1 == v2)
				break;
			v1 = v2;
			v2.clear();
		}

		cout << count - 1 << endl;
		cout << v1[0];
		for(int i = 1; i < n; i++)
			cout << " " << v1[i];
		cout << endl;
	}

	return 0;
}