// 0108
#include <iostream>
#include <vector>
using namespace std;

bool isSame(vector<int> A, vector<int> B){
	for(int i=0;i<A.size();i++)
		if(A[i] != B[i])
			return false;
	return true;
}

int main(){
	while(1){
		int n, num, count = 0;
		vector<int> A, B;

		cin>>n;
		if(n == 0)
			break;

		for(int i=0;i<n;i++){
			cin>>num;
			A.push_back(num);
			B.push_back(0);
		}

		for(int i=0;i<n;i++){
			int c = 0;
			for(int j=0;j<n;j++)
				if(A[i] == A[j])
					c++;
			B[i] = c;
		}

		while(1){
			int cnt[13] = {0};
			for(int i=0;i<n;i++){
				B[i] = A[i];
				cnt[A[i]]++;
			}

			for(int i=0;i<n;i++)
				A[i] = cnt[B[i]];

			if(isSame(A, B))
				break;
			else
				count++;
		}

		cout<<count<<endl;
		for(int i=0;i<n;i++){
			if(i != 0)
				cout<<" ";
			cout<<A[i];
		}
		cout<<endl;

	}
	return 0;
}