#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int a[20],b[20];
int res;
int n;

void f(){
//for(i=0;i<n-1;i++)cout<<a[i]<<" ";
//cout<<a[n-1]<<endl;
	int i,j;
	bool ok=true;
	for(i=0;i<n;i++){
		b[i]=0;
		for(j=0;j<n;j++){
			if(a[i]==a[j])b[i]++;
		}
		if(a[i]!=b[i])ok=false;
	}
	if(ok){
		cout<<res<<endl;
		for(i=0;i<n-1;i++)cout<<a[i]<<" ";
		cout<<a[n-1]<<endl;
	}else{
		res++;
		for(i=0;i<n;i++)a[i]=b[i];
		f();
	}
}

int main() {
	while(n=in()){
		int i;
		for(i=0;i<n;i++){
			cin>>a[i];
		}
		res=0;
		f();
	}
	return 0;
}