#include <iostream>
#include <algorithm>

using namespace std;

bool check(int a[12], int b[12], int n)
{
	bool f = true;
	
	for(int i = 0; i < n; i++){
		if(a[i] != b[i]){
			f = false;
			break;
		}
	}
	
	return f;
}

int main()
{
	int n;
	
	while(cin>>n && n){
		int a[12], b[10000], c[12], t=0, s;
		for(int i = 0; i < n; i++){
			cin >> a[i];
		}
		fill(c, c+n, -1);
		while(1){
			fill(b, b+10000, 0);
			for(int i = 0; i < n; i++){
				b[a[i]]++;
			}
			s = 1;
			for(int i = 1; i <= n; i++){
				s = max(b[s], b[i]);
			}
			if(check(a, c, n)){
				break;
			}
			
			for(int i = 0; i < n; i++){
				c[i] = a[i];
				a[i] = b[a[i]];
			}
			t++;
		}
		
		cout << (t-1) << endl;
		cout << a[0];
		for(int i = 1; i < n; i++){
			cout << " " << a[i];
		}
		cout << endl;
	}
	
	return 0;
}