#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
  int n,s[22],p[22];
  while(cin >> n && n){
    for(int i = 0; i < n; i++) cin >> p[i];

    bool f = true;
    int m = 0;
    while(f){
      f = false;
      for(int i = 0; i < n; i++) s[i] = p[i];
      for(int i = 0; i < n; i++){
	p[i] = 0;
	for(int j = 0; j < n; j++){
	  if(s[i] == s[j])p[i]++;
	}
	if(s[i]!=p[i]) f = true;
      }
      if(!f) break;
      m++;
    }
    cout << m << endl;
    for(int i = 0; i < n; i++) cout << p[i] << (i+1==n?'\n':' ');
  }
}