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

int main(){
	int n;
	vector<int> vi , vi2;
	while(cin >> n){
		if(n == 0) break;
		for(int i = 0; i < n; i++){
			int j;
			cin >> j;
			vi.push_back(j);
		}
		int counter = -1;
		do{
			vi2.clear();
			copy(vi.begin(), vi.end(), back_inserter(vi2));
			for(int i = 0; i < n; i++){
				vi[i] = count(vi2.begin(), vi2.end(), vi[i]);
			}
			counter++;
		}while(!equal(vi.begin(), vi.end(), vi2.begin()));
		cout << counter << endl;
		for(int i = 0; i < vi.size(); i++){
			if(i != 0) cout << " ";
			cout << vi[i];
		}
		cout << endl;
	}
	return 0;
}