#include<iostream>
using namespace std;

int main(){
  int n;
  while(cin>>n){
    if(!n)break;
    int a[n],b[n];
    int count = 0;
    for(int i=0;i<n;i++)
      cin>>a[i];
    while(true){
      for(int i=0;i<n;i++){
	int c = 0;
	for(int j=0;j<n;j++)
	  if(a[j] == a[i])
	    c++;
	b[i] = c;
      }
      bool bb = true;
      for(int i=0;i<n;i++){
	if(a[i] != b[i]) bb = false;
	a[i] = b[i];
      }
      if(bb)break;
      count++;
    }
    cout<<count<<endl;
    cout<<a[0];
    for(int i=1;i<n;i++)
      cout<<" "<<a[i];
    cout<<endl;
  }
  return 0;
}