#include <iostream>
#include <cstring>
using namespace std;
int a[12];
int b[12];
int main()
{
  int n,i,j,c,d,f;
  for(;;){
    cin >> n;
    if(n==0) break;
    for(i=0;i<n;i++){
      cin >> a[i];
    }
    c = 0;
    for(;;){
      f = 1;
      for(i=0;i<n;i++){
	d = 0;
	for(j=0;j<n;j++){
	  if(a[j] == a[i]) d++;
	}
	b[i] = d;
	if(a[i] != b[i]) f = 0;
      }
      if(f) break;
      memcpy(a,b,sizeof(int)*n);
      c++;
    }
    cout << c << endl << a[0];
    for(i=1;i<n;i++){
      cout << " " << a[i];
    }
    cout << endl;
  }
  return 0;
}