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


int main(){
  int n;
  while(true){
  cin >> n;
  if(n == 0)break;
  vector<int> vec,pre;
  map<int,int> counter;
  for(int i=0;i<n;i++){
    int input; cin >> input;
    counter[input]++;
    vec.push_back(input);
  }
  
  int cnt = 0;
  while(true){
    pre.clear();
    map<int,int> pc;
    for(int i=0;i<vec.size();i++){
      pre.push_back(counter[vec[i]]);
      pc[counter[vec[i]]]++;
    }  
    counter.clear();
    counter = pc;
    if(pre == vec)break;
    vec = pre;
    cnt++;
  }
  cout << cnt << endl;
  for(int i=0;i<n;i++){
    cout << pre[i];
    i == n-1?cout << endl:cout << ' ';
  }
  }
  return 0;
}