#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
	int n, a, ans, eqCount;
	vector<int> foo1, foo2;

	while( cin >> n , n ){
		ans = 0;
		foo1.clear();
		for(int i=0 ; i<n ; i++){
			cin >> a;
			foo1.push_back(a);
		}
		while( foo1 != foo2 ){
			ans++;
			foo2.clear();
			for(int i=0 ; i<foo1.size() ; i++){
				a = count( foo1.begin() , foo1.end() , foo1.at(i) );
				foo2.push_back(a);
			}
			swap( foo1 , foo2 );
		}
		cout << (ans-1) << endl;
		for(int i=0 ; i<foo2.size() ; i++){
			cout << foo2[i];
			( i == foo2.size()-1 )? cout << endl : cout << " " ;
		}
	}
}