#include<iostream>
#include<map>
#include<list>
using namespace std;

void requestAns(int num,map<int,int> dataMap,list<int> dataList){
	int count=0;
	for(;;count++){
		map<int,int> tmpMap;
		list<int> tmpList;
		list<int>::iterator it=dataList.begin();
		for(;it!=dataList.end();it++){
			int tmp=dataMap[*it];

			if(tmpMap[tmp]==0){
				tmpMap[tmp]++;
			}
			else tmpMap[tmp]++;
			tmpList.push_back(tmp);
		}

		if(tmpList==dataList)break;
		dataMap=tmpMap;
		dataList=tmpList;
	}
	cout<<count<<endl;
	list<int>::iterator it=dataList.begin();
	for(int i=0;it!=dataList.end();it++,i++){
		if(i)cout<<" ";
		cout<<dataMap[*it];
	}
	cout<<endl;

}


int
main(){
	int num;
	while(cin>>num&&num){
		map<int ,int> dataMap;
		list<int> dataList;

		for(int i=0;i<num;i++){
			int tmp;
			cin>>tmp;
			if(dataMap[tmp]==0){
				dataMap[tmp]++;
			}
			else dataMap[tmp]++;
			dataList.push_back(tmp);
			list<int>::iterator it=dataList.begin();
		}

		requestAns(num,dataMap,dataList);
	}


	return 0;
}