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

int main(){
  int n;
  while(1){
    cin >> n;
    if(n==0) break;

    int s[15]={};
    for(int i = 0; i < n; i++) cin >> s[i];
    
   
    int ans = 0;
    int c[15];
    while(1){
      bool issame = true;
      for(int i = 0; i < n; i++){
	int sum = 0;	
	for(int j = 0; j < n; j++){
	  if(s[i] == s[j] ) sum++;
	}
	if(s[i] != sum ) issame = false;
	c[i] = sum;
      }
      if(issame){
	cout << ans << endl;
      	for(int j = 0; j < n; j++){
	  if(j == n-1) cout << s[j] << "\n";
	  else cout << s[j] << " ";
	}
	break;
      }
      for(int j = 0; j < n; j++){
	s[j] = c[j];
      }
      ans++;
    }
  }
  
  return 0;
}