#include <iostream>
#include <algorithm>
using namespace std;

bool comp_array(int *prev,int *fig,int size){
  for(int i=0;i<size;i++){
    if(prev[i] != fig[i]) return true;
  }
  return false;
}

int main(){
  int n;
  int prev[13],fig[13],tmp[13];
  while(cin >> n,n){
    int cont = 0;
    for(int i=0;i<n;i++) cin >> fig[i];
    while(comp_array(prev,fig,n)){
      cont++;
      copy(fig,fig+n,prev);
      for(int i=0;i<n;i++){
	int cnt = 0;
	for(int j=0;j<n;j++){
	  if(fig[i] == fig[j]) cnt++;
	}
	tmp[i] = cnt;
      }
      copy(tmp,tmp+n,fig);
    }
    cout << --cont << endl;
    for(int i=0;i<n;i++){
      cout << fig[i] << ((i == n-1)? "\n" : " ");
    }
  }
}