#include<iostream>
using namespace std;

int main(){
  int n;
  int s[12];
  int tmp[12];
  int ans;
  int flag;

  while(1){
    cin >> n;
    if(!n)break;

    ans = 0;
    for(int i=0;i<n;i++)cin >> s[i];

    while(1){

      for(int i=0;i<n;i++){
	int c = 0;
	for(int j=0;j<n;j++)if(s[i] == s[j])c++;
	tmp[i] = c;
      }

      flag = 1;
      for(int i=0;i<n;i++)if(s[i] != tmp[i])flag=0;
    
      if(flag)break;
      else {
	ans++;
	for(int i=0;i<n;i++)s[i] = tmp[i];
      }
    }

    cout << ans << endl;
    for(int i=0;i<n-1;i++)cout << s[i] << " ";
    cout << s[n-1] << endl;
  }
}