#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;

bool debug = false;
int v[2][12];

bool isFinished(int n){
  for(int i=0;i<n;i++){
	if(v[0][i] != v[1][i]) return false;
  }
  return true;
}

int main(void){
  int n;
  while(cin >> n && n){
	int prv = 0, cur = 1;
	int tmp;
	int times = 0;
	
	memset(v, -1, sizeof(v));
	for(int i=0;i<n;i++){
	  cin >> tmp;
	  v[prv][i] = tmp;
	}

	while(!isFinished(n)){
	  for(int i=0;i<n;i++){
		int app=0;
		tmp = v[prv][i];
		for(int j=0;j<n;j++){
		  if(v[prv][j] == tmp) app++;
		}
		v[cur][i] = app;
		if(debug) cout << v[cur][i] << " ";
	  }
	  if(debug) cout << endl;
	  cur = 1 - cur;
	  prv = 1 - prv;
	  times++;
	}
	cout << times - 1 << endl;
	for(int i=0;i<n-1;i++){
	  cout << v[cur][i] << " ";
	}
	cout << v[cur][n-1] << endl;
  }
}