until (n=gets.to_i)==0
  l1=gets.split.map(&:to_i)
  l2=Array.new(n)
  count=0
  loop do
    l1.each.with_index do |num,id|
      l2[id]=l1.count{|item| item==num}
    end
    l1==l2 ? break : l1=l2.dup
    count+=1
  end
  puts "#{count}\n#{l1.join(" ")}"
end