while n = gets.chomp.to_i
	break if n==0
	s=Array.new
	c=Array.new
	s=gets.chomp.split(" ").map{|i| i.to_i}

	count=0
	loop{
		for i in 0..n-1
			c[i]=s.count(s[i])
		end
		break if s==c
		s=c
		c=[]
		count += 1
	}
	puts count
	puts s.join(" ")
end