#include <iostream>
#include <cstdio>
using namespace std;

#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)

int main() {
	int n;
	while(cin >> n && n) {
		int a[15];
		rep(i,n) {
			cin >> a[i];
		}
		int p[15], cnt = 0;
		while(1) {
			rep(i,n) {
				p[i] = 1;
			}
			rep(i,n) {
				rep2(j,i+1,n) {
					if(a[i] == a[j]) {
						p[i]++, p[j]++;
					}
				}
			}
			bool f = 1;
			rep(i,n) {
				if(a[i] != p[i]) {
					f = 0;
					break;
				}
			}
			if(f) break;
			cnt++;
			rep(i,n) {
				a[i] = p[i];
			}		
		}
		cout << cnt << endl;
		rep(i,n-1) {
			cout << p[i] << " ";
		}
		cout << p[n-1] << endl;
	}
	return 0;
}