#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;


void printv(int v[], int len) {
	int ifs = 1;
	for (int i = 0; i < len; i++) {
		if (ifs == 0)
			cout << " ";
		cout << v[i];
		ifs = 0;
	}
	cout << endl;
}

int main() {
	int n;
	while (cin >> n, n) {
		int *s = new int[n];
		for (int i = 0; i < n; i++)
			cin >> s[i];
		int *c = new int[n];
		int *p = new int[n];
		int cnt = 0;
		int vlen = sizeof(int) * n;
		memcpy(c, s, vlen);
		while (1) {
			memset(p, 0, vlen);
			for (int i = 0; i < n; i++)
				for (int j = 0; j < n; j++)
					if (c[i] == c[j])
						p[i]++;
			if (memcmp(c, p, vlen) == 0)
				break;
			memcpy(c, p, vlen);
			cnt++;
		}
		cout << cnt << endl;
		printv(p, n);

		delete[] s;
		delete[] c;
		delete[] p;
	}
	return 0;
}