#include<iostream>
using namespace std;
int main(){
  int n;
  while(cin>>n){
    if(n==0) break;
    int s[n],mems[n];
    for(int i=0;i<n;i++){
      cin >> s[i];
      mems[i] = 0;
    }
    int count = 0;
    bool ok = false;
    while(!ok){
      count++;
      for(int i=0;i<n;i++){
	int cou = 0;
	for(int j=0;j<n;j++){
	  if(s[i]==s[j]) cou++;
	}
	mems[i] = cou;
      }
      ok = true;
      for(int i=0;i<n;i++){
	if(s[i]!=mems[i]) ok = false;
	s[i] = mems[i];
      }
    }
    cout << count-1 << endl;
    for(int i=0;i<n;i++){
      if(i!=n-1) cout << s[i] << ' ';
      else cout << s[i] << endl;;
    }
  }
  return 0;
}