#include<iostream>
#include<string>
using namespace std;
int main() {
	int a[100];
	int d[21];
	int n;
	cin >> n;
	string b[2] = { "","" }, e;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		e = to_string(a[i]);
		b[1] += e;
	}
	int sum = 0;
	while (b[0] != b[1]) {
		int y =0;
		int x = 1;
		for (int i = 0; i < 20; i++)
			d[i] = 0;
		for (int i = 0; i < n; i++)
			d[a[i]]++;
		b[y] = "";
		for (int i = 0; i < n; i++) {
			a[i] = d[a[i]];
			e = to_string(a[i]);
			b[y] += e;
		}
		sum++;
		swap(b[0], b[1]);
	}
	cout << sum-1 << endl;
	for (int i = 0; i < n; i++){
		if (i == 0)
			cout << a[i];
		else
			cout << " " << a[i];
	}
	cout << endl;
}