#include<iostream>
using namespace std;

int n;
int ar1[20] = {};
int ar2[20] = {};


int func(int x){
	int val;
	int cnt = 0;;
	for(int i = 0; i < n; i++){
		if(ar1[i] == x){
			cnt++;
		}
	}
	val = cnt;
	return val;
}


int main(){
	while(cin >> n, n){
		for(int i = 0; i < n; i++){
			cin >> ar1[i]; 
		}
		int all_cnt = 0;
		while(1){
			all_cnt++;
			for(int i = 0; i < n; i++){
				ar2[i] = func(ar1[i]);		
			}

			bool flag = true;
			for(int i = 0; i < n; i++){
				if(ar1[i] != ar2[i]){
					flag = false;
				}
			}
			if(flag == true) {
				cout << all_cnt << endl;
				for(int i = 0; i < n; i++){
					cout << ar2[i] << " ";
				}
				cout << endl;
				break;
			}else{
				for(int i = 0; i < n; i++){
					ar1[i] = ar2[i];
				}
				continue;
			}
		}
	}
}