while true
    n=STDIN.gets.to_i
    exit 0 if n==0
    l=STDIN.gets.chomp.split
    for i in 0..n-1 do
        l[i]=l[i].to_i
    end

    num_op=0
    last_l=nil
    while true
        tmp=Array.new(n)
        for i in 0..n-1 do
            k = 0
            for j in 0..n-1 do
                k=k+1 if l[i]==l[j]
            end
            tmp[i] = k
        end
        last_l = l
        l = tmp
        break if last_l==l
        num_op = num_op+1
    end
    print num_op,"\n"
    for i in 0..n-1 do
        print last_l[i]
        print " " if i < n-1
    end
    print "\n"
end