import Data.List main = getLine >> getLine >>= solve . group . sort . map (read :: String -> Int) . words where solve [x] | head x `div` (length x - 1) == 4 = putStrLn $ "0 " ++ (show . length) x | otherwise = putStrLn $ (show . length) x ++ " 0" solve [x, y] = putStrLn $ (show . length) y ++ " " ++ (show . length) x