#include <vector>
#include <iostream>
#include <algorithm>

int main(){
  int n;
  while(std::cin>>n&&n){
    std::vector<int> s(n);
    std::vector<int> news(n);
    for(int &x:s) std::cin>>x;
    int count;
    for(count=0;;++count){
      for(int i=0;i<n;++i)
        news[i]=std::count(s.cbegin(),s.cend(),s[i]);
      if(news==s)break;
      s=news;
    }
    std::cout<<count<<std::endl;
    for(int i=0;i<n;++i)
      std::cout<<news[i]<<((i!=n-1)?' ':'\n');
  }
  return 0;
}