#include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<string>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstring>
#include<stack>
#include<functional>
using namespace std;

bool isSame(int n,int a[],int b[]){
	bool ans = true;
	for(int i=0;i<n;i++) if(a[i]!=b[i]) ans = false;
	return ans;
}

int main(){
	int N;
	while(cin>>N,N){
		int S[12];
		for(int i=0;i<N;i++) cin>>S[i];
		for(int i=0;;i++){
			int S_[12];
			for(int j=0;j<N;j++){
				int n = S[j], cnt = 0;
				for(int k=0;k<N;k++){
					if(n==S[k]) cnt++;
				}
				S_[j] = cnt;
			}
			if(isSame(N,S,S_)){
				printf("%d\n%d",i,S[0]);
				for(int j=1;j<N;j++) printf(" %d",S[j]); puts("");
				break;
			}
			memcpy(S,S_,sizeof(S));
		}
	}
}