#include<iostream>
#include<cstring>
using namespace std;
int main(void)
{
	int n, p[16], t[16], ans;

	while(cin >> n, n){
		for(int i = 0;i < n; i++)
			cin >> p[i];

		for(ans = 0; ; ans++){
			for(int i = 0;i < n; i++){
				int cnt = 0;
				for(int j = 0;j < n; j++){
					//if(i == j) continue;
					if(p[i] == p[j]) cnt++;
				}
				//cout << cnt << endl;
				t[i] = cnt;
			}
			bool f = false;
			for(int i = 0;i < n; i++)
				if(p[i] != t[i]) f = true;
			if(!f) break;
			memcpy(p, t, sizeof(p));
		}
		cout << ans << endl;
		cout << p[0];
		for(int i = 1;i < n; i++) cout << ' ' << p[i];
		cout << '\n';
	}
}
