#include <iostream>
#include <cstring>
using namespace std;
int main(){
  int n;
  while(cin >> n, n){
    int S[n], P[n], cnt = 0;
    memset(P, 0, sizeof(P));
    for(int i = 0 ; i < n ; i++){
      cin >> S[i];
    }
    
    while(1){
      for(int i = 0 ; i < n ; i++){
	for(int j = 0 ; j < n ; j++){
	  if(S[i] == S[j]) P[i]++;
	}
      }
      
      if(memcmp(P, S, sizeof(S)) == 0) break;

      memcpy(S, P, sizeof(P));
      memset(P, 0, sizeof(P));

      cnt++;
    }
    
    cout << cnt << endl;
    for(int i = 0 ; i < n ; i++){
      if(i == n-1) cout << P[i] << endl;
      else cout << P[i] << ' ';
    }
  }
  return 0;
}