#include <bits/stdc++.h>
using namespace std;

int main()
{
	int n;
	
	while (cin >> n , n){
		int c = 0, line[12][12] = {0};

		for (int i = 0; i < n; i++){
			cin >> line[c][i];
		}

		for (int i = 0; i < n; i++){
			line[c + 1][i] = count(line[c], line[c] + n, line[c][i]);
		}

		while (1){
			int cnt = 0;
			for (int i = 0; i < n; i++){
				if (line[c][i] == line[c + 1][i]){
					cnt++;
				}
			}
			
			if (cnt == n){
				cout << c << endl;
				cout << line[c][0];
				for (int i = 1; i < n; i++){
					cout << " " << line[c][i];
				}
				cout << endl;
				break;
			}

			c++;

			for (int i = 0; i < n; i++){
				line[c + 1][i] = count(line[c], line[c] + n, line[c][i]);
			}
		}
	}
	return (0);
}