#include <iostream>
#include <stack>
#include <algorithm>
#include <cstdio>
#include <sstream>
#include <vector>
#include <string>
#include <cmath>

#define rep(x,to) for(int x=0;x<to;x++)
#define rep2(x,from,to) for(int x=from;x<to;x++)

using namespace std;


int main(void){

int n;


	while(cin >> n ){
		if(n==0 || cin.eof()) break;
		vector<int> nb(n,0);
		rep(i,n) cin >> nb[i];
		vector<int> sv(n,0);
		int cc=0;
		while(1){
			rep(i,n) sv[i]=0;
			rep(i,n) rep(j,n) if( nb[i]==nb[j]) sv[i]++;
			bool bksw=true;
			rep(i,n) if(nb[i]!=sv[i]) {bksw=false; break;}
			if(bksw) break;
			swap(sv,nb);
			cc++;
//			rep(i,n) printf("%d ",nb[i]); printf(" ::%d\n",cc);
		}
		cout << cc <<endl;
		rep(i,n) cout << nb[i] << (i<n-1? " ": "\n");
	}
	return 0;
}