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

int main(){
	int n,c;
	int r=0;
	while(cin >> n && n){
		c = 0;
		vector<int> one(n);
		vector<int> two(n);
		for(int i=0;i<n;i++){
			cin >> one[i];
		}
		while(one != two){
			for(int k=0;k<one.size();k++){
				r=0;
				for(int i=0;i<one.size();i++)
					if(one[k]==one[i])r++;
				two[k]=r;
			}
			c++;
			swap(one,two);
		}
		cout << c-1 << endl;
		for(int i=0;i<n;i++){
			if(i)cout << " ";
			cout << one[i];
		}
		cout << endl;
	}
}