#include<vector>
#include<list>
#include<algorithm>
#include<iostream>
#define rep(i,a,b) for(i=a;i<(b);i++)
using namespace std;
int main(){
  int g,h,i,j;
  int n;
  vector<int> a,b,c;
  for(;;){
    cin>>n;
    if(n==0)
      break;
    a.clear();
    rep(i,0,n){
      int tmp;
      cin>>tmp;
      a.push_back(tmp);
    }
    g=0;
    do{
      b.clear();
      c.clear();
      rep(i,0,a.size()){
	rep(j,0,i){
	  if(a[i]==a[j])
	    break;
	}
	if(j==i)
	  b.push_back(a[i]);
      }
      rep(i,0,b.size())
	c.push_back(0);
      rep(i,0,c.size()){
	rep(j,0,n){
	  if(b[i]==a[j])
	    c[i]++;
	}
      }
      h=0;
      rep(i,0,n){
	rep(j,0,c.size()){
	  if(a[i]==b[j]){
	    if(a[i]!=c[j])
	      h=1;
	    a[i]=c[j];
	    break;
	  }
	}
      }
      if(h)
	g++;
    }while(h);
    cout<<g<<endl;
    rep(i,0,n-1)
      cout<<a[i]<<" ";
    cout<<a[i]<<endl;
  }
  return 0;
}	