#include <iostream>
#include <vector>

using namespace std;

int n;
int s[2][15];

void solve() {
	for (int i = 0; i < n; i++) {
		cin >> s[0][i];
	}
	
	int nw = 0, nx = 1;
	int rep = 0;
	while (1) {
		bool update = false;
		
		for (int i = 0; i < n; i++) {
			int t = s[nw][i];
			int cnt = 0;
			for (int j = 0; j < n; j++) {
				if (s[nw][j] == t) cnt++;
			}
			if (s[nw][i] != cnt) update = true;
			s[nx][i] = cnt;
		}
		
		if (!update) break;
		
		nw++; nw %= 2;
		nx++; nx %= 2;
		rep++;
	}
	
	cout << rep << endl;
	for (int i = 0; i < n - 1; i++) {
		cout << s[rep % 2][i] << " ";
	}
	cout << s[rep % 2][n - 1] << endl;
}

int main() {
	while (1) {
		cin >> n; if (n == 0) break;
		solve();
	}
	
	return 0;
}