#include <map>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <algorithm>
#include <iostream>

using namespace std;
/** Problem0108 : Operation of Frequency of Appearance **/
int main()
{
	int s1[12], s2[12], n;
	map<int, int> f;
	
	while (cin >> n, n!= 0) {
		for (int i=0; i<n; i++)
			cin >> s1[i];
		
		for (int j=0; ; j++) {
			for (int i=0; i<n; i++)
				f[s1[i]]++;
		
			for (int i=0; i<n; i++)
				s2[i] = f[s1[i]];
			
			f.clear();
			
			bool flag=true;
			for (int i=0; i<n; i++)
				if (s1[i] != s2[i])
					flag=false;
			
			if (flag) {
				cout << j << endl;
				cout << s2[0];
				for (int k=1; k<n; k++)
					cout << " " << s2[k];
				cout << endl;
				goto end;
			}
			for (int i=0; i<n; i++)
				s1[i] = s2[i];
		}
	end: ;
	}
}