#include<iostream>
#include<algorithm>
#include<vector>

int n,Count;
std::vector<int> Before,After;

int main(){
	while(std::cin>>n, n){
		Count=0;
		Before.clear();
		Before= After= std::vector<int>(n,0);
		for(int i=0;i<n;++i)
			std::cin>>Before[i];
		
		while(1){
			for(int i=0;i<n;++i){
				After[i]=std::count(Before.begin(),Before.end(),Before[i]);
			}
			if(Before==After)break;
			Before=After;
			++Count;
		}
		
		std::cout<<Count<<std::endl;
		for(int i=0;i<n;++i)
			std::cout<<Before[i]<<(i==n-1?"\n":" ");
	}
	return 0;
}