#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;
		vector<int> m(n), t(n);
		while(true){
			rep(i, v.size()){
				int count = 0;
				rep(j, v.size()) if(v[i] == v[j]) count++;
				m[i] = count;
			}

			bool p = true;
			rep(i, v.size()) if(m[i] != v[i]){p = false; break;}
			if(p) break;
			rep(i, v.size()) v[i] = m[i];
			ret++;
		}
		cout << ret << endl;
		rep(i, v.size()) cout << (i == 0 ? "" : " ") << v[i];
	}
}