/*****include*****/
#include <iostream>
#include <fstream>

/*****デバッグ定義*****/
//#define DEBUG
/*****マクロ定義*****/

/*****名前空間*****/
using namespace std;

/*****グローバル変数置き場*****/
int *array;
int *appearance;
int ope_num;
int n;
int count;
/*****その他関数置き場*****/
int Operation(){
	static int *app_old = new int [n];
	int num;
	int appear;
	int check;
	for(int i=0;i<n;i++){
		num = array[i];
		appear = 0;
		for(int j=0;j<n;j++)
			if(array[j] == num)
				appear ++;
		appearance[i] = appear;
	}
	for(check=0;check<n;check++)
		if(appearance[check] != array[check])
			break;
	for(int i=0;i<n;i++)
		array[i] = appearance[i];
	if(check == n)	return 1;
	count++;
	return 0;
}
/*****main関数*****/
int main(){
	/*****ファイルオープン*****/
#ifdef DEBUG
	ofstream fout("output.txt");
	ifstream fin("input.txt");
	if(!fout || !fin){
		cout << "Can't open the file.\n";
		return 0;
	}
#endif
	/*****変数置き場*****/
	/*****処理部*****/
	while(1){
		cin >> n;
		if(n==0)	break;
		array = new int [n];
		appearance = new int [n];
		for(int i=0;i<n;i++){
			cin >> array[i];
			appearance[i] = array[i];
		}
		count = 0;
		while(!Operation());
		cout << count << endl;
		for(int i=0;i<n;i++){
			if(i!=0)	cout << " ";
			cout << appearance[i];
		}
		cout << endl;
	}
	/*****処理終了後*****/
#ifdef DEBUG
	fout.close();
	fin.close();
#endif
	return 0;
}