def freq(v)
  h=Hash.new
  v.each{|x|
    if h.has_key?(x)  then
      h[x] += 1
    else
      h[x] = 1
    end
  }
  return v.map{|x| h[x]}
end

def solv(v)
  m=0
  w=[]
  while true do
    w=freq(v)
    break if v==w
    m += 1
    v = w
  end

  return [m, w]
end

if true then
fh=STDIN
else
fh=open("in0108.txt")
end
while fh.gets do
  n=$_.to_i
  break if n==0
  v=fh.gets.chomp.split.map{|x|x.to_i}
  m,f=solv(v)
  puts m
  puts f.map{|x|x.to_s}.join(" ")
end