import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector as V

main :: IO ()
main = getLine >> readLine >>= print . solve

solve :: [Int] -> Int
solve = sum . map (cmb2 . length) . group . sort . scanl (+) 0
    where
        cmb2 n = (n * (n - 1)) `div` 2

readLine :: IO [Int]
readLine = unfoldr (fmap (second (maybe B.empty snd . B.uncons)) . B.readInt) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine