#include<iostream>
using namespace std;

int ary[12];
int tmp[12];

int sumup(int k,int n) {
  int res = 0;
  int tar = ary[k];
  for(int i=0; i<n; ++i)
    if(ary[i] == tar) res++;
  return res;
}
int main() {
  int n,t;
  while(cin>>n, n) {
    for(int i=0; i<n; ++i) {
      cin>>t;
      ary[i] = t;
    }

    int count = 0;
    while(1) {
      for(int i=0; i<n; ++i)
	tmp[i] = sumup(i,n);

      count++;
      for(int i=0; i<n; ++i) {
	if(ary[i] != tmp[i]) goto NEXT;
      }

      cout<<count-1<<endl;
      for(int i=0; i<n-1; ++i)
	cout<<ary[i]<<" ";
      cout<<ary[n-1]<<endl;
      break;
    NEXT:
      for(int i=0; i<n; ++i)
	ary[i] = tmp[i];
    }
  }
}