import Control.Applicative
import Data.List
count :: Eq a => [a] -> a -> Int
count [] x = 0
count (a:as) x = if a == x then 1 + (count as x) else (count as x)



update :: [Int] -> [Int]
update xs = [count xs x |x <- xs]

solve :: [Int] -> ([Int],Int)
solve xs = let xs' = update xs in
           if xs == xs' then (xs,0) else fmap (+1) (solve xs')

     

main = do
  n <- readLn
  if n == 0 then return ()
  else do
    xs <- map read <$> words <$> getLine :: IO [Int]
    let (as,b) = solve xs
    print b
    putStrLn (intercalate " " (map show as))
    main