#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#define rep(i,l,n) for(lint i=l;i<n;i++)
#define rer(i,l,n) for(lint i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef vector<int> vi;
typedef vector<lint> vli;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main(){
	int n;
	while(cin>>n){
		if(n==0) break;
		lint ct=0;
		int s[13]={};
		rep(i,0,n){
			cin>>s[i];
		}
		int ans[13]={};
		for(ct=0;;ct++){
			rep(i,0,13){
				ans[i]=0;
			}
			int d[13]={};
			rep(i,0,n){
				d[s[i]]++;
			}
			rep(i,0,n){
				ans[i]=d[s[i]];
			}
			int c=0;
			rep(i,0,n){
				if(ans[i]==s[i]) c++;
			}
			if(c==n) break;
			rep(i,0,n){
				s[i]=ans[i];
			}
		}
		o((ct==0?1:ct));
		rep(i,0,n){
			if(i==0) cout<<ans[i];
			else cout<<" "<<ans[i];
		}
		cout<<endl;
	}
}