#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <cstdio>
using namespace std;

int main(){
	int n;
	while(cin >> n, n){
		vector<vector<int>> vvi;
		vector<int> vi;
		for(int i = 0; i < n; i++){
			int k;
			cin >> k;
			vi.push_back(k);
		}
		vvi.push_back(vi);
		int cnt = 0;
		do{
			vi.clear();
			for(int i = 0; i < vvi[cnt].size(); i++){
				vi.push_back(count(vvi[cnt].begin(), vvi[cnt].end(), vvi[cnt][i]));
			}
			vvi.push_back(vi);
			cnt++;
		}while(vvi[cnt] != vvi[cnt-1]);

		cout << cnt-1 << endl;
		for(int i = 0; i < vvi[cnt].size(); i++){
			if(i){
				cout << ' ';
			}
			cout << vvi[cnt][i];
		}
		cout << endl;
	}

	return 0;
}