#include <cstdio>
#include <iostream>
#include <string>
using namespace std;

int main(){
  int i,j,n,a[2][12],c,f,aa;
  while(1){
    cin >> n;
    if(n == 0) break;
    for(i=0;i<n;i++){
      scanf("%d",&a[0][i]); 
      a[1][i] = 0;
    }

    c = 0;
    f = 0;
    while(1){
      for(i=0;i<n;i++){
	aa = a[c%2][i];
	for(j=0;j<n;j++){
	  if(aa == a[c%2][j] && c%2 == 0) a[1][i]++;
	  else if(aa == a[c%2][j] && c%2 == 1) a[0][i]++;
	}
      }

      f = 1;
      for(i=0;i<n;i++){
	if(a[0][i] != a[1][i]){
	  f=0;
	  break;
	}
      }
      if(f == 1) break;
      for(i=0;i<n;i++) a[c%2][i] = 0;
      c++;
    }

    cout << c << endl;
    cout << a[0][0];
    for(i=1;i<n;i++) cout << " " << a[0][i];
    cout << endl;

  }
  return 0;
}