#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;


int main(){
  while(true){
    int n;
    cin >> n; 
    if(n == 0)break;
    int s[2][n];
    for(int i=0;i<n;i++)cin >> s[0][i];
    int cnt = 0;
    while(true){
      for(int i=0;i<n;i++)s[1][i] = count(s[0],s[0]+n,s[0][i]);
      bool fin = true;
      for(int i=0;i<n;i++){
	if(s[1][i] != s[0][i])fin = false;
	s[0][i] = s[1][i];
      }
      if(fin)break;
      cnt++;
    }
    cout << cnt << endl;
    for(int i=0;i<n;i++){
      cout << s[0][i];
      i==n-1?cout << endl:cout << ' ';
    }
  }
  return 0;
}