#include<iostream>
using namespace std;

int main(){
  int n;
  int s[111];
  while(1){
    cin >> n;
    int ans=0,cou=0;
    if(n == 0) break;
    for(int i=0;i<n;i++){
      cin >> s[i];
    }
    while(1){
      cou = 0;
      int cheak[111]={0};
      for(int i=0;i<n;i++){
	if(cheak[s[i]] == 0){
	  for(int j=0;j<n;j++){
	    if(s[i] == s[j]){
	      cheak[s[i]]++;
	    }
	  }
	}
      }
      for(int i=0;i<n;i++){
	s[i] = cheak[s[i]];
	if(cheak[s[i]] == s[i]){
	  cou++;
	}
      }
      if(cou == n) break;
      ans++;
    }
    cout << ans << endl;
    for(int i=0;i<n;i++){
      cout << s[i];
      if(i == n-1) cout << endl;
      else cout << " ";
    }
  }
}