#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <fstream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <assert.h>


using namespace std;


#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define clr(a) memset((a),0,sizeof(a))
#define nclr(a) memset((a),-1,sizeof(a))
#define pb push_back
#define INRANGE(x,s,e) ((s)<=(x) && (x)<(e))
#define MP(a,b) make_pair((a),(b))

int main(){
	int n;
	while(cin>>n,n){
		vector<int> S1(n), S2(n), B(10000,0);
		int count=0;
		rep(i,n){
			cin>>S1[i];
		}
		while(1){
			rep(i,B.size())B[i]=0;
			
			rep(i,S1.size())
				B[S1[i]]++;
			
			for(int j=0;j<S1.size();j++){
				S2[j]=B[S1[j]];
			}
			if(S1==S2){ 
				break;
			}
			S1=S2;count++;
		}
		cout<<count<<endl;
		rep(i,S1.size()-1)
			cout<<S1[i]<<" ";
		cout<<S1[S1.size()-1]<<endl;
	}
	return 0;
}