//	created : 15/12/27
// 	autor   : Rp7rf
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <set>

using namespace std;
#define rep(i,a) for(int i = 0 ; i < a ; i ++)
#define loop(i,a,b) for(int i = 0 ; i < a ; i ++)
#define vi vector<int>


int main(void){
	int n;
	while(cin>>n,n){
		vi in(n),l(n);
		int ret = 0;
		rep(i,n)cin>>in[i];
		while(true){
			//rep(i,n)cout<<in[i]<<" ";cout<<endl;
			int cnt[13];
			rep(i,13)cnt[i]=0;
			rep(i,n)cnt[in[i]]++;
			rep(i,n)in[i] = cnt[in[i]];
			if(in == l)break;
			ret ++;
			l = in;
		}
		cout<<ret<<endl;
		rep(i,n-1)cout<<in[i]<<" ";
		cout<<in[n-1]<<endl;
	}
}