#include <iostream>
#include <algorithm>

using namespace std;

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

int main()
{
	int a[13], b[13], d[13], n;
	bool c[13];
	
	while(1){
		cin >> n;
		if(n == 0){
			break;
		}
		for(int i = 0; i < n; i++){
			cin >> a[i];
		}
		
		int s = 0, t;
		while(check(a, n)){
			fill(b, b+13, 0);
			fill(c, c+13, false);
			for(int i = 0; i < n; i++){
				if(!c[a[i]]){
					for(int j = 0; j < n; j++){
						if(a[i] == a[j]){
							b[a[i]]++;
						}
					}
				}
				d[i] = b[a[i]];
				c[a[i]] = true;
			}
			
			for(int i = 0; i < n; i++){
				t = a[i];
				a[i] = d[i];
				d[i] = t;
			}
			s++;
		}
		cout << s << endl;
		cout << d[0];
		for(int i = 1; i < n; i++){
			cout << " " << d[i];
		}
		cout << endl;
	}
	
	return 0;
}