#include <bits/stdc++.h>

using namespace std;

typedef unsigned long long ull;
#define loop(i,a,b) for(int i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)
#define all(a) (a).begin(), (a).end()

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

int main(){
	int n;
	while(cin >> n, n){
		vector<int> v(n);
		rep(i, n) cin >> v[i];
		int ret = 0;
		while(true){
			vector<int> vv(n);
			rep(i, n){
				int c = 0;
				rep(j, n) if(v[i] == v[j]) c++;
				vv[i] = c;
			}

			bool possible = true;
			rep(i, n) if(v[i] != vv[i]) possible = false;
			if(possible) break;
			rep(i, n) v[i] = vv[i];
			ret++;
		}
		cout << ret << endl;
		rep(i, n) cout << (i == 0 ? "" : " ") << v[i];
		cout << endl;
	}
}